Skip to content

Instantly share code, notes, and snippets.

@t2mahesh
Created June 7, 2017 21:29
Show Gist options
  • Save t2mahesh/48e191d4a5c7d8b525d3bd25fc64e080 to your computer and use it in GitHub Desktop.
Save t2mahesh/48e191d4a5c7d8b525d3bd25fc64e080 to your computer and use it in GitHub Desktop.
Android Check if Service is Running
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