Android 查看手机中所有进程
真机测试的时候发现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 查看手机中所有进程的更多相关文章
- android 查看手机运行的进程列表
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=&q ...
- Android调用手机中的应用市场,去评分的功能实现
在我们常常使用的软件当中,我们经常可以看到在软件的设置界面,有一个功能那就是去评分的功能,只要我们一点击“去评分”就会调用手机中的应用市场软件.一开始我以为这个功能的实现是要遍历整个手机中的软件包名, ...
- Linux 系统中僵尸进程
Linux 系统中僵尸进程和现实中僵尸(虽然我也没见过)类似,虽然已经死了,但是由于没人给它们收尸,还能四处走动.僵尸进程指的是那些虽然已经终止的进程,但仍然保留一些信息,等待其父进程为其收尸.配图源 ...
- 用FileExplorer查看android手机中的数据库
想查看一下手机中的通讯录数据库,google之后找到了办法. 参考: http://stackoverflow.com/questions/4867379/android-eclipse-ddms-c ...
- Android中通过进程注入技术改动广播接收器的优先级
前言 这个周末又没有吊事,在家研究了怎样通过进程的注入技术改动广播接收器的优先级.关于这个应用场景是非常多的.并且也非常重要.所以就非常急的去fixed了. Android中的四大组件中有一个广播:B ...
- 【Android先进】查看手机记忆库状态和应用方法
一世 我们知道.android程序存储器通常被限制16M.当然,24M的,和android程序存储器分为2部分:native和dalvik.dalvik 就是我们寻常说的java堆.我们创建的对象是在 ...
- Android中通过进程注入技术修改广播接收器的优先级
前言 这个周末又没有吊事,在家研究了如何通过进程的注入技术修改广播接收器的优先级,关于这个应用场景是很多的,而且也很重要,所以就很急的去fixed了. Android中的四大组件中有一个广播:Broa ...
- 在Eclipse的DDMS中查看手机data文件夹中的内容
在模拟器状态下,在Eclipse的DDMS中的File Explorer下查看手机data/data中的内容是件非常轻松的事情,特别是查看databases 但是在真机模式下就全然不是那么一回事了,在 ...
- 命令行从Android手机中导出已安装APK的方法调研
一.背景 二.步骤 一.背景 很多时候,APK文件只存在于应用市场,在PC上无法直接下载.用手机下载下来后就直接安装了,也不能保存原始的APK文件. APK安装到手机后,Android系统会保存一份和 ...
随机推荐
- 为什么是梯度下降?SGD
在机器学习算法中,为了优化损失函数loss function ,我们往往采用梯度下降算法来进行优化.举个例子: 线性SVM的得分函数和损失函数分别为: ...
- SQL Server中的事务日志管理(8/9):优化日志吞吐量
当一切正常时,没有必要特别留意什么是事务日志,它是如何工作的.你只要确保每个数据库都有正确的备份.当出现问题时,事务日志的理解对于采取修正操作是重要的,尤其在需要紧急恢复数据库到指定点时.这系列文章会 ...
- php的memcache和memcached扩展区别
老生长谈的问题了.我这里就整理一下. memcache的文档在:http://pecl.php.net/package/memcache memcached的文档在:http://pecl.php.n ...
- 基于HTML5的WebGL设计汉诺塔3D游戏
在这里我们将构造一个基于HT for Web的HTML5+JavaScript来实现汉诺塔游戏. http://hightopo.com/demo/hanoi_20151106/index.html ...
- MVC中Action的执行过程
接着上一篇:MVC控制器的激活过程 一.代码现行,该伪代码大致解析了Action的执行的过程 try { Run each IAuthorizationFilter's OnAuthorization ...
- shell脚本专题之-----------全自动编译安装mysql
mysql的编译安装,在博客 开源服务专题之--------mysql的编译安装 中已经说明了,但是还是比较麻烦,尤其是一大堆命令,来手动执行,稍有不慎,就会出错.生产上一般都是先在本地测试环境进行自 ...
- 两种CSS3圆环进度条详解
晚上睡觉之前,我抽了1个多小时,研究了一下圆环进度条,结合从网上查阅的资料,我终于掌握了两种圆环的生成方法. 这次的效果就是单纯的CSS3效果,也没有写具体的JS,等以后有时间在好好整理一下吧~. 第 ...
- 使用html和css的一些经验
1.注释须知:html中注释不能这样写: <div></div><!--------这是错误写法-------> <div></div>&l ...
- .NET Framework介绍
.NET Framework 是一个集成在 Windows 中的组件,它支持生成和运行下一代应用程序与 XML Web Services. .NET Framework 旨在实现下列目标: 提供一个一 ...
- Firemonkey TEdit 切换不同 KeyboardType 样式
用代码切换 Edit 不同的键盘样式: procedure TForm1.Button1Click(Sender: TObject); begin Edit1.KeyboardType := TVir ...