/** * 服务状态的工具类 */ public class ServiceStateUtils { public static boolean getServiceState(Activity activity, String ServiceName) { boolean flag = false; ActivityManager am = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> services = am.getRunningServices(100); for (ActivityManager.RunningServiceInfo service : services) { String className = service.service.getClassName(); if (ServiceName.equals(className)) { return true; } } return false; } }
Android手机服务状态的工具类
最新推荐文章于 2021-10-19 18:19:19 发布