Android -- 查看手机中所有进程

布局

<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>

Code

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);

    }

}

我是天王盖地虎的分割线

参考:http://www.cnblogs.com/mengdd/p/3213378.html

时间: 2024-08-27 00:21:06

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

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

<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

发现一个好用的Android文件访问工具--es文件管理器,可以在同局域网下的浏览器中查看手机中的文件

如题,发现一个好用的Android文件访问工具--es文件管理器,可以在同局域网下的浏览器中查看手机中的文件 1.在手机上打开es文件管理器的远程管理器,如图:                   2.保证手机和电脑在同一个局域网下(有线或者Wifi都可以) 贴一下我的地址: (1)我电脑的IP地址(有线宽带连接): (2)手机的地址(Wifi): 3.在别的手机或者电脑上打开上面的Url(我的是:ftp://192.168.1.115:3721/),打开后就是这样的: 3. 看一下刚才在手机上

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

在我们常常使用的软件当中,我们经常可以看到在软件的设置界面,有一个功能那就是去评分的功能,只要我们一点击“去评分”就会调用手机中的应用市场软件.一开始我以为这个功能的实现是要遍历整个手机中的软件包名,去匹配市场上的大多数应用市场软件呢,这个方法一看就非常麻烦.之后,经过研究才发现其实这个功能实现非常简单. 四行代码就能实现,就能够调用出您手机上所安装的所有应用市场. 代码如下: Uri uri = Uri.parse("market://details?id="+getPackageN

查看手机中wifi密码

对于用户连接过的wifi,android系统把相关信息明文保存在 /data/misc/wifi/wpa_supplicant.conf 中,root之后可以查看,或者利用手机的备份功能进行备份,这样不用root也可以查看. 参考: 1.http://zone.wooyun.org/content/2674

android 判断手机中是否有SD卡,USB。静态判断

public static String getSDPath(Context context) { String sd = null; StorageManager storageManager = (StorageManager) context .getSystemService(Context.STORAGE_SERVICE); StorageVolume[] volumes = storageManager.getVolumeList(); for (int i = 0; i < vol

【小功能2】android获取手机信息(号码,内存,CPU,分辨率,MAC,IP,SD卡,IMEI,经纬度,信号强度等等)

为了实现一个功能,需要搜集手机信息,自己先在网上找了相关信息进行了汇总,主要是汇集手机的信息,一般想要的信息在手机设置->关于手机->状态消息里面包含了手机的各种信息,下面的代码中也主要显示了那些信息,但是源码的方法我还没有看,先把总结的贴出来.先上图(太多就截取几个).  上代码啦,太多了,就写主要代码了. // 获取Android手机中SD卡存储信息 获取剩余空间 public void getSDCardInfo() { // 在manifest.xml文件中要添加 /* * <u

Android获取手机相关信息

首先,一个小例子: package com.brio.testid; import android.app.Activity; import android.bluetooth.BluetoothAdapter; import android.os.Bundle; import android.provider.Settings.Secure; import android.widget.TextView; public class MainActivity extends Activity {

Linux 系统中僵尸进程

Linux 系统中僵尸进程 Linux 系统中僵尸进程和现实中僵尸(虽然我也没见过)类似,虽然已经死了,但是由于没人给它们收尸,还能四处走动.僵尸进程指的是那些虽然已经终止的进程,但仍然保留一些信息,等待其父进程为其收尸. 僵尸进程如何产生的? 如果一个进程在其终止的时候,自己就回收所有分配给它的资源,系统就不会产生所谓的僵尸进程了.那么我们说一个进程终止之后,还保留哪些信息?为什么终止之后还需要保留这些信息呢? 一个进程终止的方法很多,进程终止后有些信息对于父进程和内核还是很有用的,例如进程的

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

在这之前首先手机要打开ROOT权限,可以借助安卓刷机精灵等一键ROOT软件 其次像魅族.小米等手机拿到ROOT以后不能执行su命令,所以无法给手机中的文件授权,需要下载一个SuperSU权限管理器 有了他们我们就可以开始下面的步骤了: 1.window->show view->other 2. 输入 file 查找 3. 出来了吧 4. 可惜啊,data文件夹死活打不开啊, 看这个办法 当然在这之前需要把SDK配置到环境变量里面去,这里不再赘述,大家可以去搜索如何配置 On rooted de