I want to know MyService.java
is working or not?
I create this method:
private boolean isServiceAlive(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
it works fine but manager.getRunningServices()
is deprecated from API 26. So have we another good solution(method) to get a list of the services that are currently running?
Source: View source