本文整理了Java中android.app.Application.unbindService()
方法的一些代码示例,展示了Application.unbindService()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application.unbindService()
方法的具体详情如下:
包路径:android.app.Application
类名称:Application
方法名:unbindService
暂无
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onDestroy() {
if (binding!=null) {
appContext.unbindService(this);
}
disconnect();
super.onDestroy();
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onDestroy() {
appContext.unbindService(this);
disconnect();
super.onDestroy();
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onDestroy() {
appContext.unbindService(this);
disconnect();
super.onDestroy();
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onDestroy() {
appContext.unbindService(this);
disconnect();
super.onDestroy();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void bindServiceShouldCallOnServiceConnectedWithDefaultValues() {
TestService service = new TestService();
ComponentName expectedComponentName = new ComponentName("", "");
Binder expectedBinder = new Binder();
Shadows.shadowOf(context)
.setComponentNameAndServiceForBindService(expectedComponentName, expectedBinder);
context.bindService(new Intent(""), service, Context.BIND_AUTO_CREATE);
assertThat(service.name).isEqualTo(expectedComponentName);
assertThat(service.service).isEqualTo(expectedBinder);
assertThat(service.nameUnbound).isNull();
context.unbindService(service);
assertThat(service.nameUnbound).isEqualTo(expectedComponentName);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void unbindServiceAddsEntryToUnboundServicesCollection() {
TestService service = new TestService();
ComponentName expectedComponentName = new ComponentName("", "");
Binder expectedBinder = new Binder();
Intent expectedIntent = new Intent("expected");
final ShadowApplication shadowApplication = Shadows.shadowOf(context);
shadowApplication.setComponentNameAndServiceForBindServiceForIntent(expectedIntent, expectedComponentName, expectedBinder);
context.bindService(expectedIntent, service, Context.BIND_AUTO_CREATE);
context.unbindService(service);
assertThat(shadowApplication.getUnboundServiceConnections()).hasSize(1);
assertThat(shadowApplication.getUnboundServiceConnections().get(0)).isSameAs(service);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void unbindServiceWithMultipleIntentsMapping() {
TestService serviceOne = new TestService();
ComponentName expectedComponentNameOne = new ComponentName("package", "one");
Binder expectedBinderOne = new Binder();
Intent expectedIntentOne = new Intent("expected_one");
TestService serviceTwo = new TestService();
ComponentName expectedComponentNameTwo = new ComponentName("package", "two");
Binder expectedBinderTwo = new Binder();
Intent expectedIntentTwo = new Intent("expected_two");
final ShadowApplication shadowApplication = Shadows.shadowOf(context);
shadowApplication.setComponentNameAndServiceForBindServiceForIntent(expectedIntentOne, expectedComponentNameOne, expectedBinderOne);
shadowApplication.setComponentNameAndServiceForBindServiceForIntent(expectedIntentTwo, expectedComponentNameTwo, expectedBinderTwo);
context.bindService(expectedIntentOne, serviceOne, Context.BIND_AUTO_CREATE);
assertThat(serviceOne.nameUnbound).isNull();
context.unbindService(serviceOne);
assertThat(serviceOne.name).isEqualTo(expectedComponentNameOne);
context.bindService(expectedIntentTwo, serviceTwo, Context.BIND_AUTO_CREATE);
assertThat(serviceTwo.nameUnbound).isNull();
context.unbindService(serviceTwo);
assertThat(serviceTwo.name).isEqualTo(expectedComponentNameTwo);
TestService serviceDefault = new TestService();
context.bindService(new Intent("default"), serviceDefault, Context.BIND_AUTO_CREATE);
assertThat(serviceDefault.nameUnbound).isNull();
context.unbindService(serviceDefault);
assertThat(serviceDefault.name).isNull();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void unbindServiceShouldRemoveServiceConnectionFromListOfBoundServiceConnections() {
final ShadowApplication shadowApplication = Shadows.shadowOf(context);
final ServiceConnection expectedServiceConnection = new EmptyServiceConnection();
assertThat(context.bindService(new Intent("connect"), expectedServiceConnection, 0)).isTrue();
assertThat(shadowApplication.getBoundServiceConnections()).hasSize(1);
assertThat(shadowApplication.getUnboundServiceConnections()).hasSize(0);
context.unbindService(expectedServiceConnection);
assertThat(shadowApplication.getBoundServiceConnections()).hasSize(0);
assertThat(shadowApplication.getUnboundServiceConnections()).hasSize(1);
assertThat(shadowApplication.getUnboundServiceConnections().get(0))
.isSameAs(expectedServiceConnection);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void unbindServiceShouldCallOnServiceDisconnectedWhenNotPaused() {
TestService service = new TestService();
ComponentName expectedComponentName = new ComponentName("", "");
Binder expectedBinder = new Binder();
Intent expectedIntent = new Intent("expected");
Shadows.shadowOf(context)
.setComponentNameAndServiceForBindServiceForIntent(
expectedIntent, expectedComponentName, expectedBinder);
context.bindService(expectedIntent, service, Context.BIND_AUTO_CREATE);
ShadowLooper.pauseMainLooper();
context.unbindService(service);
assertThat(service.nameUnbound).isNull();
ShadowLooper.unPauseMainLooper();
assertThat(service.nameUnbound).isEqualTo(expectedComponentName);
}
代码示例来源:origin: osmandapp/osmand-api-demo
public void cleanupResources() {
if (mIOsmAndAidlInterface != null) {
app.unbindService(mConnection);
}
}
代码示例来源:origin: roomanl/AndroidDownload
@Override
public void unbindService(ServiceConnection conn) {
app.unbindService(conn);
}
代码示例来源:origin: hubing8658/UPnP-DLNA-Demo
/**
* 关闭upnp服务
*
* @param mApp
*/
public void closeUpnpService(Application mApp) {
if (upnpService != null) {
upnpService.getRegistry().removeAllLocalDevices();
mApp.unbindService(conn);
}
}
内容来源于网络,如有侵权,请联系作者删除!