下面列出了android.app.Service#onUnbind ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private boolean handleOnUnbindOne(Intent intent) throws Exception {
ServiceInfo info = ApkManager.getInstance().resolveServiceInfo(intent, 0);
if (info == null) {
return false;
}
Service service = (Service) this.mNameService.get(info.name);
if (service == null) {
return false;
}
intent.setExtrasClassLoader(getClassLoader(info.applicationInfo));
return service.onUnbind(intent);
}
private boolean handleOnUnbindOne(Intent intent) throws Exception {
ServiceInfo info = PluginManager.getInstance().resolveServiceInfo(intent, 0);
if (info != null) {
Service service = mNameService.get(info.name);
if (service != null) {
ClassLoader classLoader = getClassLoader(info.applicationInfo);
intent.setExtrasClassLoader(classLoader);
return service.onUnbind(intent);
}
}
return false;
}
private static void unbindService(final Service service, final Intent intent) {
if (service instanceof AidlService)
((AidlService) service).closeBinder();
else try {
final boolean rebind = service.onUnbind(intent); // TODO: Support rebind if true is returned.
if (rebind) throw new UnsupportedOperationException("Sorry, onRebind() is not yet supported.");
} catch (final RuntimeException e) {
Log.e(TAG, "Error unbinding " + service, e);
}
}