I have started services in foreground like this
@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;
}
Sometime I think it run on multiple instances somehow because I have logic in my my method that runs after few minutes and it is doing entries in db and sometimes it just make duplicate entries and im not sure it can happen!! Also I have checks on rows some ids that if it exists in table already then dont insert it. Any suggestions?
Note: There is a lot of code that's why I didnt pasted all of it and just explained the scenario.