/**
* 启动Service前,做个判断,否则容易引起崩溃
* @param mContext
* @param className
* @return
*/
public boolean isServiceRunning(Context mContext, String className)
{
int i;
ActivityManager activityManager = (ActivityManager)
mContext.getSystemService(Context.ACTIVITY_SERVICE);
List
serviceList =
activityManager.getRunningServices(30);
for (i = 0; i < serviceList.size(); ++i)
{
if (serviceList.get(i).service.getClassName().equals(className))
{
return true;
}
}
return false;
}
阅读(1580) | 评论(0) | 转发(0) |