Created
February 22, 2019 01:56
-
-
Save alexshr/18ae2ca43a77555e8fe8244cb594f927 to your computer and use it in GitHub Desktop.
isServiceRunning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean isServiceRunning() { | |
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); | |
boolean isRunning = false; | |
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { | |
if (LocationService.class.getName().equals(service.service.getClassName())) { | |
isRunning = true; | |
} | |
} | |
Timber.d("isRunning=%b", isRunning); | |
return isRunning; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment