Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.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 终止活动进程时服务重新启动_Android_Android Service - Fatal编程技术网

Android 终止活动进程时服务重新启动

Android 终止活动进程时服务重新启动,android,android-service,Android,Android Service,我有一个活动,它通过我的服务的android:process属性在单独的流程中启动服务 我的服务的onStartCommand()函数返回START\u 我通过“最近使用的应用程序”按钮将活动进程刷走,从而终止活动进程,然后服务进程重新启动 我想知道在活动进程终止时,是否有办法保持服务运行 I want to know if there is a way to keep the service running when the activity process is killed. 不,无法保

我有一个活动,它通过我的服务的
android:process
属性在单独的流程中启动服务

我的服务的
onStartCommand()
函数返回
START\u

我通过“最近使用的应用程序”按钮将活动进程刷走,从而终止活动进程,然后服务进程重新启动

我想知道在活动进程终止时,是否有办法保持服务运行

I want to know if there is a way to keep the service running when the activity process is killed.
不,无法保持服务运行。因为

Closed by the user via the Running Services screen in Settings.

Closed by the user via a task killer.

Closed by Android to free up memory in times of need.

但你可以做到


-->您可以使用广播接收器重新启动服务(当来电、启动完成、收到短信等时,根据您的要求使用此功能)

您找到解决方案了吗?@Perry\u ml没有。我放弃了这个项目。