ActivityManager mActivityManager =(ActivityManager)getSystemService(ACTIVITY_SERVICE);
List<RunningServiceInfo> infos = mActivityManager.getRunningServices(30); //30是最大值
for(RunningServiceInfo info : infos){
if(info.service.getClassName().equals("com.baoyz.swipemenulistviewsample.PushNotificationService")){//服务的全称,包名加上类名
pushNotificationServiceStated=true;
Toast.makeText(sContext, "服务已开启", Toast.LENGTH_LONG).show();
}
}
安卓当中如何判断某一项服务是否开启
最新推荐文章于 2021-05-25 18:06:03 发布