I have a service that, when I start it, I plan to work with the alarm manager at 00:00, I want to check if my service is working or not?
when I check Settings โ Applications โ Launch tasks, My service exists in a cached process, so the code below does not work, because my service, which marks when the service starts, can someone help me?
private boolean isServiceRunning(String serviceName) { ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> l = am.getRunningServices(50); Iterator<ActivityManager.RunningServiceInfo> i = l.iterator(); while (i.hasNext()) { ActivityManager.RunningServiceInfo runningServiceInfo = (ActivityManager.RunningServiceInfo) i.next(); if( runningServiceInfo.service.getClassName().equals(serviceName) ) { return true; } } return false; }
source share