This example will test whether a service is running in android if you know it’s package name.
Run this sample of code to check this.
private boolean checkMyServiceRunningOrNot() { ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if ( "com.example.your_Service" .equals(service.service.getClassName())) { return true ; } } return false ; } |