/** * 判断服务是否还活着 * * @param serviceName * @return */ public static boolean isRuningService(Context context, String serviceName) { // 校验服务是否还活着 ActivityManager am = (ActivityManager) context .getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> infos = am.getRunningServices(100); for (RunningServiceInfo info : infos) { String name = info.service.getClassName(); if (serviceName.equals(name)) { return true; } } return false; }