Created
June 7, 2017 21:29
-
-
Save t2mahesh/48e191d4a5c7d8b525d3bd25fc64e080 to your computer and use it in GitHub Desktop.
Android Check if 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
public static boolean isServiceRunning(Context context, String className) { | |
ActivityManager manager = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE); | |
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)){ | |
if(className.equals(service.service.getClassName())) { | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment