package cn.cbd.mobilesaft.activity.utils;import java.util.List;import android.app.ActivityManager;import android.app.ActivityManager.RunningServiceInfo;import android.content.Context;public class SettingCenterUtil{/*** 判断一个服务是否是正在运行* @param context* @param serviceName serivce全名* @return 正在运行返回true 不运行返回false*/public static boolean isServiceRunning(Context context,String serviceName){ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);Listinfos = am.getRunningServices(20);for(RunningServiceInfo info:infos){//包名+类名String myServiceName = info.service.getClassName();if(myServiceName.equals(serviceName)){return true;}}return false;}}