相关疑难解决方法(0)

如果多次启动服务会发生什么?

如果我有以下代码:

Intent intent = new Intent(this,DownloadService.class);     
for(int i=0;i<filesArray.length;i++){        
     startService(intent);          
}
Run Code Online (Sandbox Code Playgroud)

在此代码中DownloadService扩展IntentService.

所以现在,当我打电话时startService(intent),这意味着每次调用我都会启动一项新服务,startService(intent)或者这意味着它DownloadService会运行一次,然后每次调用startService(intent)它时,只会使用不同的startId传递不同的意图.

这是否有意义,以及其中哪一个是这样的?

android

111
推荐指数
3
解决办法
5万
查看次数

标签 统计

android ×1