Java Code Examples for android.app.Service#onDestroy()
The following examples show how to use
android.app.Service#onDestroy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServiceManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * 停止某个插件Service, 当全部的插件Service都停止之后, ProxyService也会停止 * * @param targetIntent targetIntent * @return int */ int stopService(Intent targetIntent) { ServiceInfo serviceInfo = selectPluginService(targetIntent); if (serviceInfo == null) { Log.e(TAG, "can not found service: " + targetIntent.getComponent()); return 0; } Service service = mServiceMap.get(serviceInfo.name); if (service == null) { Log.w(TAG, "can not running, are you stopped it multi-times?"); return 0; } service.onDestroy(); mServiceMap.remove(serviceInfo.name); if (mServiceMap.isEmpty()) { // 没有Service了, 这个没有必要存在了 Log.d(TAG, "service all stopped, stop proxy"); Context appContext = MApplication.getInstance(); appContext.stopService(new Intent().setComponent(new ComponentName(appContext.getPackageName(), PluginProxyService.class.getName()))); } return 1; }
Example 2
Source File: ServiceManager.java From understand-plugin-framework with Apache License 2.0 | 6 votes |
/** * 停止某个插件Service, 当全部的插件Service都停止之后, ProxyService也会停止 * @param targetIntent * @return */ public int stopService(Intent targetIntent) { ServiceInfo serviceInfo = selectPluginService(targetIntent); if (serviceInfo == null) { Log.w(TAG, "can not found service: " + targetIntent.getComponent()); return 0; } Service service = mServiceMap.get(serviceInfo.name); if (service == null) { Log.w(TAG, "can not runnning, are you stopped it multi-times?"); return 0; } service.onDestroy(); mServiceMap.remove(serviceInfo.name); if (mServiceMap.isEmpty()) { // 没有Service了, 这个没有必要存在了 Log.d(TAG, "service all stopped, stop proxy"); Context appContext = UPFApplication.getContext(); appContext.stopService(new Intent().setComponent(new ComponentName(appContext.getPackageName(), ProxyService.class.getName()))); } return 1; }
Example 3
Source File: ServiceManager20.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
/** * 停止某个插件Service, 当全部的插件Service都停止之后, ProxyService也会停止 * * @param targetIntent targetIntent * @return int */ public int stopService(Intent targetIntent) { ServiceInfo serviceInfo = selectPluginService(targetIntent); if (serviceInfo == null) { Log.w(TAG, "can not found service: " + targetIntent.getComponent()); return 0; } String processName3 = ProcessUtil.getProcessNameViaManager(MApplication.getInstance()); Log.d(TAG, "3processName:" + processName3); Log.d(TAG, "3mServiceMap.size:" + mServiceMap.size()); Log.d(TAG, "3mServiceMap.get(serviceInfo.name):" + serviceInfo.name); Service service = mServiceMap.get(serviceInfo.name); if (service == null) { Log.w(TAG, "can not runnning, are you stopped it multi-times?"); return 0; } service.onDestroy(); mServiceMap.remove(serviceInfo.name); if (mServiceMap.isEmpty()) { // 没有Service了, 这个没有必要存在了 Log.d(TAG, "service all stopped, stop proxy"); Context appContext = MApplication.getInstance(); appContext.stopService(new Intent().setComponent(new ComponentName(appContext.getPackageName(), PluginProxyService.class.getName()))); } return 1; }
Example 4
Source File: ServcesManager.java From letv with Apache License 2.0 | 5 votes |
private void handleOnDestroyOne(ServiceInfo targetInfo) { Service service = (Service) this.mNameService.get(targetInfo.name); if (service != null) { service.onDestroy(); this.mNameService.remove(targetInfo.name); Object token = findTokenByService(service); this.mTokenServices.remove(token); this.mServiceTaskIds.remove(token); QueuedWorkCompat.waitToFinish(); ApkManager.getInstance().onServiceDestory(null, targetInfo); } QueuedWorkCompat.waitToFinish(); }
Example 5
Source File: ServcesManager.java From letv with Apache License 2.0 | 5 votes |
public void onDestroy() { for (Service service : this.mTokenServices.values()) { service.onDestroy(); } this.mTokenServices.clear(); this.mServiceTaskIds.clear(); this.mNameService.clear(); QueuedWorkCompat.waitToFinish(); }
Example 6
Source File: ServcesManager.java From DroidPlugin with GNU Lesser General Public License v3.0 | 5 votes |
private void handleOnDestroyOne(ServiceInfo targetInfo) { Service service = mNameService.get(targetInfo.name); if (service != null) { service.onDestroy(); mNameService.remove(targetInfo.name); Object token = findTokenByService(service); mTokenServices.remove(token); mServiceTaskIds.remove(token); service = null; QueuedWorkCompat.waitToFinish(); PluginManager.getInstance().onServiceDestory(null, targetInfo); } QueuedWorkCompat.waitToFinish(); }
Example 7
Source File: ServcesManager.java From DroidPlugin with GNU Lesser General Public License v3.0 | 5 votes |
public void onDestroy() { for (Service service : mTokenServices.values()) { service.onDestroy(); } mTokenServices.clear(); mServiceTaskIds.clear(); mNameService.clear(); QueuedWorkCompat.waitToFinish(); }
Example 8
Source File: LocalAidlServices.java From deagle with Apache License 2.0 | 5 votes |
static void destroyService(final Service service) { unregisterComponentCallbacks(service.getApplication(), service); try { final long start = Debug.threadCpuTimeNanos(); service.onDestroy(); logExcessiveElapse(start, 5, service, ".onDestroy()"); } catch (final RuntimeException e) { Log.e(TAG, "Error destroying " + service, e); } }