Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.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_Service - Fatal编程技术网

如何杀死在后台连续运行的android服务

如何杀死在后台连续运行的android服务,android,service,Android,Service,在我的服务中,我正在运行一个无限循环,如何从活动中停止这个无限循环 我尝试过stopService(),但它并没有终止服务。我的循环如下 while(i>=1) { i++; } 我的问题是如何停止这个无限循环服务。尝试使用 stopService(新意图(ServiceTest.this、ServiceName.class)) 呼叫解除绑定服务(serviceConnection);

在我的服务中,我正在运行一个无限循环,如何从活动中停止这个无限循环 我尝试过
stopService()
,但它并没有终止服务。我的循环如下

while(i>=1)
{
   i++;
}
我的问题是如何停止这个无限循环服务。

尝试使用

stopService(新意图(ServiceTest.this、ServiceName.class))

呼叫解除绑定服务(serviceConnection);