欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

在Android中 獲取正在運(yùn)行的Service 實(shí)例

 更新時(shí)間:2013年04月19日 16:15:21   作者:  
本篇文章小編為大家介紹,在Android中 獲取正在運(yùn)行的Service 實(shí)例。需要的朋友參考下
public class ServiceList extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		TextView tv = new TextView(this);
ActivityManager activityManger = (ActivityManager) getSystemService(ACTIVITY_SERVICE);// 獲取Activity管理器 List<ActivityManager.RunningServiceInfo> serviceList = activityManger.getRunningServices(30);// 從窗口管理器中獲取正在運(yùn)行的Service tv.setText(getServicesName(serviceList)); setContentView(tv); } private boolean ServiceIsStart(List<ActivityManager.RunningServiceInfo> list, String className) {// 判斷某個(gè)服務(wù)是否啟動(dòng) for (int i = 0; i < list.size(); i++) { if (className.equals(list.get(i).service.getClassName())) return true; } return false; } private String getServicesName(List<ActivityManager.RunningServiceInfo> list) {// 獲取所有服務(wù)的名稱 String res = ""; for (int i = 0; i < list.size(); i++) { res += list.get(i).service.getClassName() + "/n"; } return res; } }

相關(guān)文章

最新評(píng)論