真机测试的时候发现DDMS对进程的显示很不给力,一些进程管理工具又不显示包名。

  所以就自己写了一个小程序,查看自己手机中的进程,显示当前时间和进程的包名:

  程序运行截图:

  布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <Button
android:id="@+id/updateBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Update ProcessInfos" /> <TextView
android:id="@+id/time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textStyle="bold" /> <ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" > <TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:padding="5dp"/>
</ScrollView> </LinearLayout>

  主要代码:

package com.example.helloprocess;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List; import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView; public class HelloProcessActivity extends Activity
{
private TextView mTextView = null;
private TextView mTime = null;
private Button mButton = null;
private String mText = ""; @Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hello_process); mTextView = (TextView) findViewById(R.id.text);
mTime = (TextView) findViewById(R.id.time);
mButton = (Button) findViewById(R.id.updateBtn); mButton.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v)
{
updateProcessInfo();
}
}); } private void updateProcessInfo()
{
mText = "";
mTextView.setText(mText); // 获取ActivityManager
ActivityManager activityManager = (ActivityManager) this
.getSystemService(Context.ACTIVITY_SERVICE); // 更新时间
updateTimeInfo(); // 获取进程信息***************************************************
List<RunningAppProcessInfo> infos = activityManager
.getRunningAppProcesses(); for (RunningAppProcessInfo info : infos)
{
String name = info.processName; mText = mTextView.getText().toString();
mText += name + "\n\n";
mTextView.setText(mText); } } private void updateTimeInfo()
{
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
String time = df.format(new Date());
System.out.println(time);// new Date()为获取当前系统时间 mTime.setText(time); } }

Android 查看手机中所有进程的更多相关文章

  1. android 查看手机运行的进程列表

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=&q ...

  2. Android调用手机中的应用市场,去评分的功能实现

    在我们常常使用的软件当中,我们经常可以看到在软件的设置界面,有一个功能那就是去评分的功能,只要我们一点击“去评分”就会调用手机中的应用市场软件.一开始我以为这个功能的实现是要遍历整个手机中的软件包名, ...

  3. Linux 系统中僵尸进程

    Linux 系统中僵尸进程和现实中僵尸(虽然我也没见过)类似,虽然已经死了,但是由于没人给它们收尸,还能四处走动.僵尸进程指的是那些虽然已经终止的进程,但仍然保留一些信息,等待其父进程为其收尸.配图源 ...

  4. 用FileExplorer查看android手机中的数据库

    想查看一下手机中的通讯录数据库,google之后找到了办法. 参考: http://stackoverflow.com/questions/4867379/android-eclipse-ddms-c ...

  5. Android中通过进程注入技术改动广播接收器的优先级

    前言 这个周末又没有吊事,在家研究了怎样通过进程的注入技术改动广播接收器的优先级.关于这个应用场景是非常多的.并且也非常重要.所以就非常急的去fixed了. Android中的四大组件中有一个广播:B ...

  6. 【Android先进】查看手机记忆库状态和应用方法

    一世 我们知道.android程序存储器通常被限制16M.当然,24M的,和android程序存储器分为2部分:native和dalvik.dalvik 就是我们寻常说的java堆.我们创建的对象是在 ...

  7. Android中通过进程注入技术修改广播接收器的优先级

    前言 这个周末又没有吊事,在家研究了如何通过进程的注入技术修改广播接收器的优先级,关于这个应用场景是很多的,而且也很重要,所以就很急的去fixed了. Android中的四大组件中有一个广播:Broa ...

  8. 在Eclipse的DDMS中查看手机data文件夹中的内容

    在模拟器状态下,在Eclipse的DDMS中的File Explorer下查看手机data/data中的内容是件非常轻松的事情,特别是查看databases 但是在真机模式下就全然不是那么一回事了,在 ...

  9. 命令行从Android手机中导出已安装APK的方法调研

    一.背景 二.步骤 一.背景 很多时候,APK文件只存在于应用市场,在PC上无法直接下载.用手机下载下来后就直接安装了,也不能保存原始的APK文件. APK安装到手机后,Android系统会保存一份和 ...

随机推荐

  1. EF总结

    1.Entity Framework 查询历史最严重bug求解十万火急 2.http://www.cnblogs.com/badly1984/p/3203565.html 3.Entity Frame ...

  2. Go语言接口

    接口是面向对象的必备属性之一,即便是像C语言这种面向过程的语言也可以通过指向函数的指针来实现接口.我们熟知的面向对象语言中更是少不了接口.最近闲了下来,又可以开始学习Go语言了,发现Go语言的接口吸收 ...

  3. IIS MIME类型大全

    文件如果下载不了,可能是iis中的MIME设置问题.格式前面为后辍名,后面为对应的MIME型(例如:rar application/x-rar-compressed 表示.RAR对应的是applica ...

  4. 代码创建数据库_表--SqlServer数据库

    /*1.创建数据库的时候需要设置的基本属性: 数据库名称 逻辑名称 初始大小 文件增长 路径*/ --语法: -- create database 数据库名称 -- on [primary]--创建数 ...

  5. easyui的window插件再次封装

    easyui的window插件再次封装 说明:该插件弹出的弹出框在最顶层的页面中,而不是在当前页面所在的iframe中,它的可拖动范围是整个浏览器窗口:所以不能用JS的parent对象获取弹出它的父页 ...

  6. Win10通用程序 UWP版HtmlAgilityPack UWP应用使用示例

    Win10 UWP版HtmlAgilityPack,UWP应用使用示例下载. Win10 发布了一个多星期,sdk是随着一起发布的,我安装好vs2015和sdk 开发UWP 通用程序. 在做网络解析的 ...

  7. VS2015如何创建单元测试并启动调试

    1: 添加单元测试 2:打开单元测试类 关键点: 类上加上标记:[TestClass],方法上添加标记:[TestMethod],方法输出使用:Assert.IsNotNull(s,"测试失 ...

  8. Lesson: The "Hello World!" Application

    Lesson: The "Hello World!" Application The sections listed below provide detailed instruct ...

  9. 一不小心把oschina给戒了

    不知怎么回事,逐渐变成一周看一次oschina了.

  10. AngularJS例子 ng-repeat遍历输出 通过js的splice方法删除当前行

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...