private void unbind() { if (mAuthenticator != null) { mAuthenticator = null; mContext.unbindService(this); } }
public void unbindFromService() { mApplicationContext.unbindService(mServiceConnection); }
@Override public void onDestroy() { super.onDestroy(); if (inAppBillingService != null) { context.unbindService(serviceConnection); } } }
public void stop(Context context) { sensorMgr.unregisterListener(this); context.unbindService(mConnection); }
public void stop(Context context) { sensorMgr.unregisterListener(this); context.unbindService(mConnection); }
public void stop(Context context) { sensorMgr.unregisterListener(this); context.unbindService(mConnection); }
public void onServiceDisconnected(ComponentName name) { sender = null; try { context.unbindService(this); } catch (IllegalArgumentException ex) { // Do nothing, the connection was already unbound } callback(null); }
public void stop (Context context) { context.unbindService(mConnection); if (microphone != null) microphone.cancel(true); }
public void stop(Context context) { sensorMgr.cancelTriggerSensor(sensorListener, bumpSensor); context.unbindService(mConnection); } private TriggerEventListener sensorListener = new TriggerEventListener() {
@Override public void onServiceConnected(ComponentName cname, IBinder service) { try { ((DMBinder) service).getDownloadManager().checkForRunningMission(location, name, check); } catch (Exception err) { Log.w(TAG, "checkForRunningMission() callback is defective", err); } // TODO: find a efficient way to unbind the service. This destroy the service due idle, but is started again when the user start a download. context.unbindService(this); }
@Override public void unbindByContext(final Context context) { if (!bindContexts.contains(context)) { return; } if (FileDownloadLog.NEED_LOG) { FileDownloadLog.d(this, "unbindByContext %s", context); } bindContexts.remove(context); if (bindContexts.isEmpty()) { releaseConnect(false); } Intent i = new Intent(context, serviceClass); context.unbindService(this); context.stopService(i); }
/** * Method reserved for system use */ @Override public void unbindService(ServiceConnection conn) { application.getApplicationContext().unbindService(conn); application.getApplicationContext().stopService(serviceIntent); serviceConnected = false; } }
@Override protected void onDestroy() { super.onDestroy(); // Stop monitoring the power switch LocalService<SwitchPower> switchPowerService = getSwitchPowerService(); if (switchPowerService != null) switchPowerService.getManager().getImplementation().getPropertyChangeSupport() .removePropertyChangeListener(this); getApplicationContext().unbindService(serviceConnection); }
@Override protected void onDestroy() { super.onDestroy(); if (upnpService != null) { upnpService.getRegistry().removeListener(registryListener); } // This will stop the UPnP service if nobody else is bound to it getApplicationContext().unbindService(serviceConnection); } // DOC:SERVICE_BINDING
@Override public void onDestroy() { super.onDestroy(); if (mBinder == null || mAdapter == null) return; mBinder.removeMissionEventListener(mAdapter.getMessenger()); mBinder.enableNotifications(true); mContext.unbindService(mConnection); mAdapter.deleterDispose(null); mBinder = null; mAdapter = null; }
@Test public void unbind_throws_noException() throws Exception { connection.onServiceConnected(null, binderMock); binderMock.verifyStartArguments(jobData, noopCallback); assertFalse(connection.wasUnbound()); doThrow(IllegalArgumentException.class).when(contextMock).unbindService(connection); connection.unbind(); assertTrue(connection.wasUnbound()); verify(contextMock).unbindService(connection); }
@Test public void stopWithResult_keepConnectionOpen() throws Exception { assertFalse(connection.wasUnbound()); connection.onStop(job, true); assertFalse(connection.wasUnbound()); verify(contextMock, never()).unbindService(connection); }
@Test public void unbind() throws Exception { connection.onServiceConnected(null, binderMock); binderMock.verifyStartArguments(jobData, noopCallback); assertFalse(connection.wasUnbound()); connection.unbind(); assertTrue(connection.wasUnbound()); verify(contextMock).unbindService(connection); }
@Test public void onStop_doNotSendResult() throws Exception { connection.onServiceConnected(null, binderMock); binderMock.verifyStartArguments(jobData, noopCallback); assertFalse(connection.wasUnbound()); connection.onStop(job, false); binderMock.verifyStopArguments(jobData, false); assertTrue(connection.wasUnbound()); verify(contextMock).unbindService(connection); }
@Test public void onStop_unbindsAfterRemoteException() throws Exception { connection.onServiceConnected(null, binderMock); binderMock.verifyStartArguments(jobData, noopCallback); assertFalse(connection.wasUnbound()); binderMock.setStopException(new RemoteException("something bad happened")); connection.onStop(job, true); binderMock.verifyStopArguments(jobData, true); assertTrue(connection.wasUnbound()); verify(contextMock).unbindService(connection); }