Android 如何检测一个服务是否还在运行?
public static boolean isServiceStarted(Context context,String PackageName){ boolean isStarted =false; try{ int intGetTastCounter = 1000; ActivityManager mActivityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> mRunningService = mActivityManager.getRunningServices(intGetTastCounter); for (ActivityManager.RunningServiceInfo amService : mRunningService){ if(0 == amService.service.getPackageName().compareTo(PackageName)){ isStarted = true; break; } } }catch(SecurityException e){ e.printStackTrace(); } return isStarted; }
补充:移动开发 , Android ,