I also thought a lot about this before, but I found a simple solution. Put a static variable in the service If the service is running, give the value to true, and if not, give the value to false.
public static Boolean serviceRunning = false;
public int onStartCommand(Intent intent, int flags, int startId) {
serviceRunning = true;
...
}
@Override
public void onDestroy()
{
serviceRunning = false;
}
Like this.
© 2024 OneMinuteCode. All rights reserved.