如果我有以下的code:
If I have the following code:
Intent intent = new Intent(this,DownloadService.class);
for(int i=0;i<filesArray.length;i++){
startService(intent);
}
在此code下载服务延伸IntentService。所以,当我打电话startService(意向),现在这是否意味着我开始了新的服务,每次startService(意向)被调用或者这是否意味着下载服务一旦运行,然后我每次调用startService(意向)时它会只是通过不同的意图有不同的startId。这是否有意义,以及这些哪一个是这样吗?
In this code DownloadService extends IntentService. So now when I'm calling startService(intent) does that mean that i'm starting a new service everytime startService(intent) is called or does that mean that DownloadService is ran once and then each time I call startService(intent) it will just pass a different intent with a different startId. Does this make sense, and which one of these is the case ?
该服务将只在一个实例中运行。但是,每次启动服务时, onStartCommand()
方法被调用。
The Service will only run in one instance. However, everytime you start the service, the onStartCommand()
method is called.
这是记载here