引用:http://www.cmd100.com/bbs/forum-redirect-tid-6807-goto-lastpost.html

一段获取正在运行的后台service的代码,如下:
//RunningServicesInfo
public static String getRunningServicesInfo(Context context) {
StringBuffer serviceInfo = new StringBuffer();
final ActivityManager activityManager = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningServiceInfo> services = activityManager.getRunningServices(100);

Iterator<RunningServiceInfo> l = services.iterator();
while (l.hasNext()) {
RunningServiceInfo si = (RunningServiceInfo) l.next();
serviceInfo.append("pid: ").append(si.pid);
serviceInfo.append("\nprocess: ").append(si.process);
serviceInfo.append("\nservice: ").append(si.service);
serviceInfo.append("\ncrashCount: ").append(si.crashCount);
serviceInfo.append("\nclientCount: ").append(si.clientCount);
serviceInfo.append("\nactiveSince: ").append(ToolHelper.formatData(si.activeSince));
serviceInfo.append("\nlastActivityTime: ").append(ToolHelper.formatData(si.lastActivityTime));
serviceInfo.append("\n\n");
}
return serviceInfo.toString();
}

更多相关文章

  1. Android代码总结,Sdcard和图片相关
  2. android 下载不了源代码?
  3. android 2.2 完全 退出 ---程序代码
  4. Android 功能代码总结

随机推荐

  1. 【Android】Android中不同手机分辨率适配
  2. Android菜鸟日记18-button的按钮效果
  3. Android 的上下文菜单: Context Menu
  4. android中的按键处理
  5. 什么是 Android?
  6. android 移植 一 准备
  7. Android studio创建java项目
  8. android中文字高亮设置案例
  9. 【转】Linux Kernel and Android 休眠与
  10. 写一个Android输入法01——最简步骤