Android手机服务状态的工具类

来源:互联网 发布:怎样限制手机安装软件 编辑:程序博客网 时间:2024/05/22 13:17
/** * 服务状态的工具类 */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;    }}
原创粉丝点击