| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
gxw6
9年前发布

android判断服务是否是运行状态

    /**            * 判断服务是否处于运行状态.            * @param servicename            * @param context            * @return            */            public static boolean isServiceRunning(String servicename,Context context){                ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);                List<RunningServiceInfo>  infos = am.getRunningServices(100);                for(RunningServiceInfo info: infos){                    if(servicename.equals(info.service.getClassName())){                        return true;                    }                }                return false;            }