Skip to content

Instantly share code, notes, and snippets.

@alexshr
Created February 22, 2019 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexshr/18ae2ca43a77555e8fe8244cb594f927 to your computer and use it in GitHub Desktop.
Save alexshr/18ae2ca43a77555e8fe8244cb594f927 to your computer and use it in GitHub Desktop.
isServiceRunning
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