Android examples for android.app:ActivityManager
is Service Worked
import android.app.ActivityManager; import android.content.Context; import android.content.pm.PackageInfo; import java.util.ArrayList; import java.util.List; public class Main{ public static boolean isServiceWorked(Context context, String serviceName) { ActivityManager myManager = (ActivityManager) context .getSystemService(Context.ACTIVITY_SERVICE); ArrayList<ActivityManager.RunningServiceInfo> runningService = (ArrayList<ActivityManager.RunningServiceInfo>) myManager .getRunningServices(30); for (int i = 0; i < runningService.size(); i++) { if (runningService.get(i).service.getClassName().toString() .equals(serviceName)) { return true; }/*from w ww. ja v a 2s. c o m*/ } return false; } }