Search...

Monday, March 12, 2012

How to find out that service is running or not in Android?


private boolean isMyServiceRunning() {
   ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
   for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
       if ("com.test.DataService".equals(service.service.getClassName())) {
           return true;
       }
   }
   return false;
}

No comments:

Post a Comment