I want to know what MyService.javaworks 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 is manager.getRunningServices()deprecated from API 26. So, is there another good solution (method) to get a list of services that are currently running?
source
share