Android 判断某个服务(service)是否运行
判断某个服务是否正在运行的方法
实现代码:
/**
*
*
*@parammContext
*@paramserviceName
*是包名+服务的类名(例如:net.loonggg.testbackstage.TestService)
*@returntrue代表正在运行,false代表服务没有正在运行
*/
publicbooleanisServiceWork(ContextmContext,StringserviceName){
booleanisWork=false;
ActivityManagermyAM=(ActivityManager)mContext
.getSystemService(Context.ACTIVITY_SERVICE);
ListmyList=myAM.getRunningServices(40);
if(myList.size()<=0){
returnfalse;
}
for(inti=0;i
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!