服务可以在Android的多个实例上运行吗?

时间:2018-09-05 12:46:21

标签: java android service

我已经像这样在前台开始服务

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    super.onStartCommand(intent, flags, startId);
    if(serviceRunning == false){
        startInForeground();
        serviceRunning = true;
    }
    return Service.START_STICKY;
}

有时我认为它可以在多个实例上运行,因为我的方法中有逻辑,几分钟后运行,并且它正在db中进行输入,有时它只是重复输入,我不确定它会发生!!另外,我在行上检查了一些ID,如果它已经存在于表中,则不要插入它。有什么建议吗?

注意:有很多代码是为什么我没有全部粘贴并仅说明场景的原因。

0 个答案:

没有答案
相关问题