Ejemplo n.º 1
0
  @Override
  public void close() {

    context.unregisterReceiver(onRequestElevationUpdate);
    context.unregisterReceiver(onFileChanged);
    srtmAccess.close();
  }
Ejemplo n.º 2
0
 /** Unregister listen in the context of the application */
 private void unregistred() {
   try {
     applicationContext.unregisterReceiver(statusReceiver);
     applicationContext.unregisterReceiver(connectionListener);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 3
0
 /** Closes and releases resources. May be also used to unregister broadcast listeners. */
 public void close() {
   try {
     mContext.unregisterReceiver(mBondingBroadcastReceiver);
     mContext.unregisterReceiver(mPairingRequestBroadcastReceiver);
   } catch (Exception e) {
     // the receiver must have been not registered or unregistered before
   }
   if (mBluetoothGatt != null) {
     mBluetoothGatt.close();
     mBluetoothGatt = null;
   }
   mUserDisconnected = false;
 }
Ejemplo n.º 4
0
  /** Shuts down the manager and releases resources. */
  public void shutdown() {
    LogUtils.log(this, Log.VERBOSE, "Shutdown requested.");

    // We must immediately destroy registered receivers to prevent a leak,
    // as the context backing this registration is to be invalidated.
    mContext.unregisterReceiver(mRefreshReceiver);
    mContext.unregisterReceiver(mLocaleChangedReceiver);

    // We cannot shutdown resources related to the database until all tasks
    // have completed. Flip the flag to indicate a client of this manager
    // requested a shutdown and attempt the operation.
    mShouldShutdownClient = true;
    maybeShutdownClient();
  }
Ejemplo n.º 5
0
  /*
     close() must be called by the user class. It destroys registered
     receivers. If it is not called, it may cause memory leaks because of the registered
     callback services.
  */
  public void close() {
    mBlueToothAdapter.cancelDiscovery();

    if (stateChangeRegistered) {
      mainActivity.unregisterReceiver(mReceiver);
      stateChangeRegistered = false;
    }

    if (broadcastRegistered) {
      mainActivity.unregisterReceiver(this);
      broadcastRegistered = false;
    }

    disconnect();
  }
Ejemplo n.º 6
0
 private void unregisterReceiver() {
   ContentResolver resolver = mContext.getContentResolver();
   resolver.unregisterContentObserver(mAudioObv);
   resolver.unregisterContentObserver(mImagesObv);
   resolver.unregisterContentObserver(mVideoObv);
   mContext.unregisterReceiver(mMediaScanReceiver);
 }
        @Override
        public void onReceive(Context context, Intent intent) {
          if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) {
            long reference = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
            Log.d(
                TAG,
                "refrence:"
                    + reference
                    + "#my reference:"
                    + mDownloadReference
                    + ", intent:"
                    + intent.toString());
            if (mDownloadReference == reference) {
              DownloadManager downloadManager;
              mContext.unregisterReceiver(mReceiver);
              downloadManager =
                  (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
              Uri apkUri = downloadManager.getUriForDownloadedFile(reference);

              if (apkUri != null) {
                Intent installIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
                installIntent.setData(apkUri);
                mContext.startActivity(installIntent);
              }
            }
          }
        }
Ejemplo n.º 8
0
 private void unregisterReceiver() {
   if (mProxyReceiver == null) {
     return;
   }
   mContext.unregisterReceiver(mProxyReceiver);
   mProxyReceiver = null;
 }
Ejemplo n.º 9
0
 protected void finalize() {
   try {
     mContext.unregisterReceiver(mVbirtStateChangeReceiver);
   } catch (IllegalArgumentException e) {
     PhoneLog.e(LOG_TAG, "IllegalArgumentException happened in finalized().");
   }
 }
  private void unRegisterReceivers() {

    // EventBus.getDefault().post(new HeartRateEvent("Unregistering receivers"));

    try {
      mContext.unregisterReceiver(mGattUpdateReceiver);
    } catch (Exception exp) {
      exp.printStackTrace();
    }

    try {
      mContext.unregisterReceiver(mBlueToothReceiver);
    } catch (Exception exp) {
      exp.printStackTrace();
    }
  }
Ejemplo n.º 11
0
 public void unregister() {
   if (mRegisteredContext == null) {
     throw new IllegalStateException("Not registered");
   }
   mRegisteredContext.unregisterReceiver(this);
   mRegisteredContext = null;
 }
 @Override
 public void onDestroy() {
   if (null != mIncomingCallBroadcastReceiver) {
     mContext.unregisterReceiver(mIncomingCallBroadcastReceiver);
     mIncomingCallBroadcastReceiver = null;
   }
 }
Ejemplo n.º 13
0
    public final void a()
    {
label0:
        {
            synchronized (j)
            {
                if (i)
                {
                    break label0;
                }
            }
            return;
        }
        if (a != null && c != null)
        {
            break MISSING_BLOCK_LABEL_39;
        }
        abyte0;
        JVM INSTR monitorexit ;
        return;
        try
        {
            a.unregisterReceiver(c);
        }
        catch (Exception exception1) { }
        d.removeCallbacks(e);
        i = false;
        abyte0;
        JVM INSTR monitorexit ;
    }
  /**
   * Sets up a broadcastReceiver to listen for wifi hardware getting disabled
   *
   * @param disabled Callback listener to be fired if the wifi hardware is disabled
   */
  private synchronized void investWifiInterest(final HardwareCallback callback, final int index) {
    IntentFilter wifiInterestIntent = new IntentFilter();
    wifiInterestIntent.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);

    if (wifiInterestReceiver != null) {
      mContext.unregisterReceiver(wifiInterestReceiver);
    }

    wifiInterestReceiver =
        new BroadcastReceiver() {

          public void onReceive(Context context, Intent intent) {

            switch (mWifiManager.getWifiState()) {
              case WifiManager.WIFI_STATE_DISABLED:
              case WifiManager.WIFI_STATE_DISABLING:
              case WifiManager.WIFI_STATE_UNKNOWN:
                mContext.unregisterReceiver(wifiInterestReceiver);
                callback.hardwareDisabled(index, HardwareCallback.REASON_WIFI_USER);
                break;
            }
          }
        };

    mContext.registerReceiver(wifiInterestReceiver, wifiInterestIntent);
  }
Ejemplo n.º 15
0
 @Override
 public void onReceive(Context context, Intent intent) {
   // Log.v(TAG, "Receiving: " + intent.getAction());
   if (intent.getAction().equals(OppProbe.getStatusAction(probeName))) {
     OppProbe.Status status = new OppProbe.Status(intent.getExtras());
     if (probeName.equals(status.getName())) {
       Log.i(TAG, "Is a status action for " + probeName);
       long nonce = intent.getLongExtra(OppProbe.ReservedParamaters.NONCE.name, 0L);
       Log.i(TAG, "Nonce is " + nonce + "'");
       if (!sent && nonce != 0L) {
         sent = true;
         expirationTimer.cancel();
         try {
           context.unregisterReceiver(DataResponder.this);
         } catch (IllegalArgumentException e) {
           // already removed;
         }
         final Intent i = new Intent(OppProbe.getGetAction(probeName));
         Log.i(TAG, "Sending intent '" + i.getAction() + "'");
         i.setPackage(context.getPackageName()); // Send only to this app for right now
         i.putExtra(OppProbe.ReservedParamaters.PACKAGE.name, context.getPackageName());
         if (requestId != null && !"".equals(requestId)) {
           i.putExtra(OppProbe.ReservedParamaters.REQUEST_ID.name, requestId);
         }
         i.putExtra(OppProbe.ReservedParamaters.REQUESTS.name, requests);
         i.putExtra(OppProbe.ReservedParamaters.NONCE.name, nonce);
         context.sendBroadcast(i);
       }
     }
   }
 }
Ejemplo n.º 16
0
 private void unregisterScreenStateBroadcastReceiver() {
   try {
     mContext.unregisterReceiver(mScreenStateReceiver);
   } catch (Exception IllegalArgumentException) {
     MoPubLog.d("Failed to unregister screen state broadcast receiver (never registered).");
   }
 }
Ejemplo n.º 17
0
 @Override
 public synchronized void stop() {
   mContext.unregisterReceiver(mUsbReceiver);
   Log.d(TAG, "stop: " + this);
   stateChange(State.FINISHED);
   super.stop();
 }
 @Override
 public void onReceive(Context context, Intent intent) {
   final String action = intent.getAction();
   if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
     final int state =
         intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
     switch (state) {
       case BluetoothAdapter.STATE_ON:
         EventBus.getDefault().post(new HeartRateEvent("Bluetooth turned on"));
         mBpm = HeartRateConstants.HEART_RATE_MONITOR_NOT_CONNECTED;
         EventBus.getDefault().post(new BlueToothLEEvent(mBpm));
         if (mContext != null) {
           mContext.registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());
         }
         scanLeDevice(true);
         break;
       case BluetoothAdapter.STATE_OFF:
         EventBus.getDefault().post(new HeartRateEvent("Bluetooth turned off"));
         stopListening();
         if (mContext != null) {
           try {
             mContext.unregisterReceiver(mGattUpdateReceiver);
           } catch (Exception exp) {
             exp.printStackTrace();
           }
         }
         break;
     }
   }
 }
Ejemplo n.º 19
0
 public void unRegisterSmsReceiver(Context context) {
   try {
     context.unregisterReceiver(this);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 20
0
 /** 取消广播 */
 private void unregistReceiver() {
   try {
     mContext.unregisterReceiver(mReceiver);
   } catch (Exception e) {
     Logger.printStackTrace(e);
   }
 }
Ejemplo n.º 21
0
 private void unregisterReceiver() {
   if (!this.mReceiverRegistered) return;
   Context localContext = this.mContext;
   BroadcastReceiver localBroadcastReceiver = this.mNowPlayingReceiver;
   localContext.unregisterReceiver(localBroadcastReceiver);
   this.mReceiverRegistered = false;
 }
Ejemplo n.º 22
0
 public void onDestroy() {
   if (mFavoriteReceiver != null) {
     mContext.unregisterReceiver(mFavoriteReceiver);
     mFavoriteReceiver = null;
   }
   Log.i("cuiqian", "pee onDestroy");
   mContext.unbindService(serviceConnection);
 }
Ejemplo n.º 23
0
  private void unregisterReceivers() {
    mContext.unregisterReceiver(mConnectivityReceiver);
    if (DEBUG) Log.d(TAG, " --- unregister receivers");

    // Reset variables maintained by ConnectivityReceiver.
    mWifiLock.release();
    mConnected = false;
  }
Ejemplo n.º 24
0
 /**
  * Clear internal resources.
  *
  * <p>This method should be called by the main activity's {@code onDestroy()} method.
  */
 public static synchronized void onDestroy(Context context) {
   if (sRetryReceiver != null) {
     Log.v(TAG, "Unregistering retry receiver");
     sRetryReceiverContext.unregisterReceiver(sRetryReceiver);
     sRetryReceiver = null;
     sRetryReceiverContext = null;
   }
 }
Ejemplo n.º 25
0
 /**
  * Terminate the connection manager
  *
  * @throws PayloadException
  * @throws NetworkException
  * @throws ContactManagerException
  */
 public void terminate() throws PayloadException, NetworkException, ContactManagerException {
   if (sLogger.isActivated()) {
     sLogger.info("Terminate the IMS connection manager");
   }
   if (mBatteryLevelListener != null) {
     mCtx.unregisterReceiver(mBatteryLevelListener);
     mBatteryLevelListener = null;
   }
   if (mNetworkStateListener != null) {
     mCtx.unregisterReceiver(mNetworkStateListener);
     mNetworkStateListener = null;
   }
   stopImsConnection(TerminationReason.TERMINATION_BY_SYSTEM);
   mCurrentNetworkInterface.unregister();
   if (sLogger.isActivated()) {
     sLogger.info("IMS connection manager has been terminated");
   }
 }
 /** {@inheritDoc} */
 public void cancel() {
   locationManager.removeUpdates(singleUpatePI);
   try {
     context.unregisterReceiver(singleUpdateReceiver);
   } catch (IllegalArgumentException e) {
     Log.v(TAG, "Receiver already unregistered.");
     // e.printStackTrace();
   }
 }
  public void stop(@NonNull Context context) {
    try {
      context.unregisterReceiver(this);
    } catch (IllegalArgumentException e) {
      FlitchioLog.i("BroadcastReceiver was not registered: no need to stop it");
    }

    callback = null;
  }
 public void unregisterAllReceivers() {
   for (BroadcastReceiver r : receivers) {
     try {
       context.unregisterReceiver(r);
     } catch (IllegalArgumentException e) {
       // Ignore, broadcast receiver has already been removed.
     }
   }
 }
Ejemplo n.º 29
0
 public void onDestroy() {
   //	        super.onDestroy();
   // Make sure we're not doing discovery anymore
   if (adapter != null) {
     adapter.cancelDiscovery();
   }
   // Unregister broadcast listeners
   mContext.unregisterReceiver(mBluetoothReceiver);
 }
Ejemplo n.º 30
0
 @Override
 public void setFastBroadCastReceiverRegistered(boolean registered) {
   if (registered) {
     receiver = new WifiBroadcastReceiver(manager, channel, peerListener, connectionInfoListener);
     context.registerReceiver(receiver, broadcastReceiverIntentFilter);
   } else {
     context.unregisterReceiver(receiver);
   }
 }