Last active
December 27, 2015 03:49
-
-
Save ishitcno1/7262044 to your computer and use it in GitHub Desktop.
Detect if service is running in android.
From http://stackoverflow.com/questions/600207/android-check-if-a-service-is-running
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 isMyServiceRunning() { | |
ActivityManager activityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE); | |
for (ActivityManager.RunningServiceInfo serviceInfo: activityManager.getRunningServices(Integer.MAX_VALUE)) { | |
if (ShakeLockService.class.getName().equals(serviceInfo.service.getClassName())) { | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment