/** * * @param mcontext * @param serviceName getPackageName()+".当前包名."+"服务name" * @return */ public static boolean serviceIsRun(Context mcontext, String serviceName){ boolean serviceIsRun =false; ActivityManager activityManager = (ActivityManager) mcontext .getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> runningServices = activityManager.getRunningServices(100); for (int i = 0; i < runningServices.size(); i++) { String s = runningServices.get(i).service.getClassName(); if (s.equals(serviceName)) { serviceIsRun =true; } } return serviceIsRun; }
android 检查某个服务是否正在运行
最新推荐文章于 2024-09-02 18:19:21 发布