we can check if a service is running or not .This is very simple you can check by RunningServiceInfo class.
private boolean checkMyServiceRunning() {
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if ("com.test.MyServiceClassname".equals(service.service.getClassName())) {
return true;
}
}
return false;
}
No comments:
Post a Comment