本文整理了Java中android.content.Context.unbindService()
方法的一些代码示例,展示了Context.unbindService()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.unbindService()
方法的具体详情如下:
包路径:android.content.Context
类名称:Context
方法名:unbindService
暂无
代码示例来源:origin: android-hacker/VirtualXposed
private void unbind() {
if (mAuthenticator != null) {
mAuthenticator = null;
mContext.unbindService(this);
}
}
代码示例来源:origin: k9mail/k-9
public void unbindFromService() {
mApplicationContext.unbindService(mServiceConnection);
}
代码示例来源:origin: facebook/facebook-android-sdk
@Override
public void onDestroy() {
super.onDestroy();
if (inAppBillingService != null) {
context.unbindService(serviceConnection);
}
}
}
代码示例来源:origin: guardianproject/haven
public void stop(Context context) {
sensorMgr.unregisterListener(this);
context.unbindService(mConnection);
}
代码示例来源:origin: guardianproject/haven
public void stop(Context context) {
sensorMgr.unregisterListener(this);
context.unbindService(mConnection);
}
代码示例来源:origin: guardianproject/haven
public void stop(Context context) {
sensorMgr.unregisterListener(this);
context.unbindService(mConnection);
}
代码示例来源:origin: facebook/facebook-android-sdk
public void onServiceDisconnected(ComponentName name) {
sender = null;
try {
context.unbindService(this);
} catch (IllegalArgumentException ex) {
// Do nothing, the connection was already unbound
}
callback(null);
}
代码示例来源:origin: guardianproject/haven
public void stop (Context context)
{
context.unbindService(mConnection);
if (microphone != null)
microphone.cancel(true);
}
代码示例来源:origin: guardianproject/haven
public void stop(Context context) {
sensorMgr.cancelTriggerSensor(sensorListener, bumpSensor);
context.unbindService(mConnection);
}
private TriggerEventListener sensorListener = new TriggerEventListener() {
代码示例来源:origin: TeamNewPipe/NewPipe
@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);
}
代码示例来源:origin: lingochamp/FileDownloader
@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);
}
代码示例来源:origin: AltBeacon/android-beacon-library
/**
* Method reserved for system use
*/
@Override
public void unbindService(ServiceConnection conn) {
application.getApplicationContext().unbindService(conn);
application.getApplicationContext().stopService(serviceIntent);
serviceConnected = false;
}
}
代码示例来源:origin: 4thline/cling
@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);
}
代码示例来源:origin: 4thline/cling
@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
代码示例来源:origin: TeamNewPipe/NewPipe
@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;
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@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);
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@Test
public void stopWithResult_keepConnectionOpen() throws Exception {
assertFalse(connection.wasUnbound());
connection.onStop(job, true);
assertFalse(connection.wasUnbound());
verify(contextMock, never()).unbindService(connection);
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@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);
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@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);
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@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);
}
内容来源于网络,如有侵权,请联系作者删除!