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

  7.                 Iterator l = services.iterator();
  8.                 while (l.hasNext()) {
  9.                         RunningServiceInfo si = (RunningServiceInfo) l.next();
  10.                         serviceInfo.append("pid: ").append(si.pid);
  11.                         serviceInfo.append("\nprocess: ").append(si.process);
  12.                         serviceInfo.append("\nservice: ").append(si.service);
  13.                         serviceInfo.append("\ncrashCount: ").append(si.crashCount);
  14.                         serviceInfo.append("\nclientCount: ").append(si.clientCount);
  15.                         serviceInfo.append("\nactiveSince: ").append(ToolHelper.formatData(si.activeSince));
  16.                         serviceInfo.append("\nlastActivityTime: ").append(ToolHelper.formatData(si.lastActivityTime));
  17.                         serviceInfo.append("\n\n");
  18.                 }
  19.                 return serviceInfo.toString();
  20.         }

更多相关文章

  1. Android上传文件到Django服务器
  2. Android(安卓)屏幕截图 代码
  3. Android(安卓)网络图片查看器
  4. Android(安卓)开发常用代码片段
  5. Android沉浸式状态栏
  6. 【Android】【应用信息】获取应用列表
  7. Android中获取SQL Server中的数据
  8. Android(安卓)GPS获得经纬度并得到该坐标精确地址
  9. android > 获取 通讯录 信息

随机推荐

  1. 使用相同的colgroup时,多个HTML表具有不同
  2. GET错误Glyphicon-halflings-regular.ttf
  3. 绝对定位的div层,别再让flash盖住了
  4. 点击后如何使弹出文本消失?
  5. 使用Objective-C将HTML文本转换为纯文本
  6. html响应式布局_媒体查询
  7. HTML实现图片上传前预览
  8. HTML5、CSS3应用教程之 跟DIV说Bey!Bey!
  9. 1、html/css:基本样式总结
  10. 浏览器的地址栏尺寸是否会影响CSS媒体查