/** 查看服务是否开启*/
    public static Boolean isServiceRunning(Context context, String serviceName) {
        //获取服务方法  参数 必须用大写的Context!!!
        ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningServiceInfo> infos = am.getRunningServices(100);
        for (RunningServiceInfo info : infos) {
            String className = info.service.getClassName();
            if(serviceName.equals(className))
                return true;
        }
        return false;
    }

相关文章:

  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2022-02-15
  • 2022-03-05
  • 2021-11-09
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案