易网时代-编程资源站
Welcome
微信登录
编程资源
图片资源库
蚂蚁家优选
PDF转换器
软件资源
软件开发
、
小程序制作
、
系统集成与运维
、
空间租用
、
硬件开发
、
视频监控
、
技术咨询与支持
——联系电话:0311-88999002/88999003
首页
/
操作系统
/
Linux
/
Android判断某服务是否正在运行
Android判断某服务是否正在运行:
/**
* 用来判断服务是否运行.
* @param context
* @param className 判断的服务名字
* @return true 在运行 false 不在运行
*/
public
static
boolean
isServiceRunning(Context mContext,String className) {
boolean
isRunning =
false
;
ActivityManager activityManager = (ActivityManager)
mContext.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningServiceInfo> serviceList
= activityManager.getRunningServices(
30
);
if
(!(serviceList.size()>
0
)) {
return
false
;
}
for
(
int
i=
0
; i<serviceList.size(); i++) {
if
(serviceList.get(i).service.getClassName().equals(className) ==
true
) {
isRunning =
true
;
break
;
}
}
return
isRunning;
}
收藏该网址
版权所有©石家庄振强科技有限公司2024
冀ICP备08103738号-5
网站地图