想要天天向上,就要懂得享受学习。图老师为大家推荐在Android中 获取正在运行的Service 实例,精彩的内容需要你们用心的阅读。还在等什么快点来看看吧!
【 tulaoshi.com - 编程语言 】
public class ServiceList extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);TextView tv = new TextView(this);
ActivityManager activityManger = (ActivityManager) getSystemService(ACTIVITY_SERVICE);// 获取Activity管理器ListActivityManager.RunningServiceInfo serviceList = activityManger.getRunningServices(30);// 从窗口管理器中获取正在运行的Servicetv.setText(getServicesName(serviceList));setContentView(tv);}private boolean ServiceIsStart(ListActivityManager.RunningServiceInfo list, String className) {// 判断某个服务是否启动for (int i = 0; i list.size(); i++) {if (className.equals(list.get(i).service.getClassName()))return true;}return false;}private String getServicesName(ListActivityManager.RunningServiceInfo list) {// 获取所有服务的名称String res = "";for (int i = 0; i list.size(); i++) {res += list.get(i).service.getClassName() + "/n";}return res;}}
来源:http://www.tulaoshi.com/n/20160219/1594265.html
看过《在Android中 获取正在运行的Service 实例》的人还看了以下文章 更多>>
如果您有什么好的建议或者疑问,可以联系我们。 商务合作QQ:3272218541;3282258740。商务合作微信:13319608704;13319603564。
加好友请备注机构名称。让我们一起学习、一起进步tulaoshi.com 版权所有 © 2019 All Rights Reserved. 湘ICP备19009391号-3
微信公众号