Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Handle IntentService桌面事件_Android_Android Intentservice - Fatal编程技术网

Android Handle IntentService桌面事件

Android Handle IntentService桌面事件,android,android-intentservice,Android,Android Intentservice,我想处理桌面事件。IntentService将接收意图,启动工作线程,并根据需要停止服务,但我还没有找到onStop方法。它有ondestory(),但实际上不能调用ondestory()方法 只有当系统资源(内存、cpu时间等)不足并决定终止您的活动/应用程序或有人对您的活动调用finish()时,才会调用onDestroy 我可以在onStop IntentService time中添加代码吗?您可以使用stopSelf()停止服务。要在服务停止前执行任务,可以在线程结束后编写自定义回调/广

我想处理桌面事件。IntentService将接收意图,启动工作线程,并根据需要停止服务,但我还没有找到onStop方法。它有
ondestory()
,但实际上不能调用
ondestory()
方法

只有当系统资源(内存、cpu时间等)不足并决定终止您的活动/应用程序或有人对您的活动调用finish()时,才会调用onDestroy

我可以在onStop IntentService time中添加代码吗?

您可以使用
stopSelf()
停止服务。要在服务停止前执行任务,可以在线程结束后编写自定义回调/广播
通知用户界面。

如果要对IntentService进行子类化,则应在服务的生命周期中使用
OnHandleContent(Intent-Intent)
。您的服务可能会很快移动到
onDestroy
,因为
OnHandleContent
中没有代码


此外,它可能会很快移动到
onDestroy
,因为
IntentService
是自动线程化的,可能只是启动调用
OnHandleContent
的工作线程,然后移动到
onDestroy

是的,看起来只有在服务执行后才能编写广播。但这是下载IntentService,有很多下载线程,我需要在所有下载完成后处理事件并发送回调/广播。问题是如何处理onStop IntentService?服务可能正在移动到onDestroy?我不确定。。