真机测试的时候发现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. FCFS,SSTF,SCAN,FIFO,LRO考点题解

    四.应用题 ( 本大题共5 小题,50 分 ) 1. 假设某系统中有五个进程,每个进程的执行时间(单位:ms)和优先数如下表所示(优先数越小,其优先级越高). 进程 执行时间 优先数 P1 P2 P3 ...

  2. Microsoft Azure News(4) Azure新D系列虚拟机上线

    <Windows Azure Platform 系列文章目录> Update 2016-05-07 注意事项: Azure的数据中心建设是有先后顺序的,最早是落地了A系列的虚拟机,然后是D ...

  3. Tornado框架

    Tornado介绍 Tornado 是 FriendFeed 使用的可扩展的异步非阻塞式 web 服务器及其相关工具的开源版本.这个 Web 框架看起来有些像web.py(豆瓣用这个写的) 或者 Go ...

  4. elasticsearch 文档

    elasticsearch 文档 文档格式 索引中最基本的单元叫做文档 document. 在es中文档的示例如下: { "_index": "questions&quo ...

  5. CSS魔法堂:说说Float那个被埋没的志向

    前言  定位系统中第一难理解就是Normal flow,而第二就非Float莫属了,而Float难理解的原因有俩,1. 一开头我们就用错了:2. 它跟Normal flow靠得太近了.本文尝试理清Fl ...

  6. C#--静态成员的生命周期

  7. [Offer收割]编程练习赛3 - 题目3 : 智力竞赛

    智力竞赛 Problem's Link ---------------------------------------------------------------------------- Mea ...

  8. MVC中使用EF+MySQL

    最近一段时间,想在EF中使用MySQL,于是就进行了测试. 我的环境是VS2013+EF6+MySQL5.7.4 首先要下载MySQL For VisualStudio 1.1.4.Connector ...

  9. 使用ajax和js无刷新改变页面内容和地址栏URL

    发现一个可以改变地址栏,而不导致页面刷新的东东. Chrome, FF测试通过,不支持IE. 实现目标 页面的跳转(前进后退,点击等)不重新请求页面 页面URL与页面展现内容一致(符合人们对传统网页的 ...

  10. js动态显示表格的汇总信息和详细信息

    我在做数据结果展示的时候,想要实现一个如下的功能:    用户可以选择一个时间段,默认显示这个时间段的汇总数据,当鼠标点击这个时间段的时候,将显示每个时间点的详细数据,再次点击的时候,详细数据收起,只 ...