package com.ray.time;
import android.app.Activity;
import android.os.Bundle;
import java.util.Timer;
import java.util.TimerTask;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
public class timetest extends Activity {
int times = 0;
Timer timer = new Timer();
Handler handler = new Handler(){
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
setTitle("hear me?");
break;
}
super.handleMessage(msg);
}
};
TimerTask task = new TimerTask(){
public void run() {
if(times>1)
{timer.cancel();
}
else{
String key = String.valueOf(times);
Message message = new Message();
message.what = 1;
Log.v("times开始",key);
fetch_cpu_info();
fetch_disk_info();
fetch_netcfg_info();
getMemoryInfo();
times ++;
handler.sendMessage(message);
}
}
};
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
timer.schedule(task,2,5000);
fetch_version_info();
getSystemProperty();
}
public static String fetch_disk_info(){//系统信息-disk
String result = null;
CMDExecute cmdexe = new CMDExecute();
String ACTIVITY_TAG = "diskinfo";
String[] args = { "/system/bin/df" };
result = cmdexe.run(args, "/system/bin/");
Log.v(ACTIVITY_TAG,result);
return result;
}
public static String fetch_netcfg_info(){//系统信息=net
String result = null;
CMDExecute cmdexe = new CMDExecute();
String ACTIVITY_TAG = "netcfginfo";
String[] args = { "/system/bin/netcfg" };
result = cmdexe.run(args, "/system/bin/");
Log.v(ACTIVITY_TAG,result);
return result;
}
public static String fetch_version_info(){//系统信息-系统版本
String result = null;
String ACTIVITY_TAG = "systeminfo";
CMDExecute cmdexe = new CMDExecute();
String[] args = {"/system/bin/cat","/proc/version"};
result = cmdexe.run(args, "/system/bin/");
Log.v(ACTIVITY_TAG,result);
return result;
}
public static String fetch_cpu_info(){//系统信息-cpu
String result = null;
String ACTIVITY_TAG = "cpuinfo";
CMDExecute cmdexe = new CMDExecute();
String[] args = {"/system/bin/cat","/proc/cpuinfo"};
result = cmdexe.run(args, "/system/bin/");
Log.v(ACTIVITY_TAG,result);
return result;
}
public static void getSystemProperty(){//系统信息
initProperty("java.vendor.url");
initProperty("java.class.path");
initProperty("user.home");
initProperty("java.class.version");
initProperty("os.version");
initProperty("java.vendor");
initProperty("user.dir");
initProperty("user.timezone");
initProperty("path.separator");
initProperty("os.name");
initProperty("os.arch");
initProperty("line.separator");
initProperty("user.name");
initProperty("java.version");
initProperty("java.home");
}
public static String initProperty(String key){
String result = null;
String ACTIVITY_TAG = key;
result= System.getProperty(key);
Log.v(ACTIVITY_TAG,"result"+result);
return result;
}
public static String getMemoryInfo() {
String ACTIVITY_TAG = "meminfo";
// StringBuffer memoryInfo = new StringBuffer();
// ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
//
// ActivityManager.MemoryInfo outInfo = new ActivityManager.MemoryInfo();
// activityManager.getMemoryInfo(outInfo);
// memoryInfo.append("\nTotal Available Memory :").append(
// outInfo.availMem >> 10).append("k");
// memoryInfo.append("\nTotal Available Memory :").append(
// outInfo.availMem >> 20).append("M");
// memoryInfo.append("\nIn low memory situation:").append(
// outInfo.lowMemory);
// Log.v(ACTIVITY_TAG, memoryInfo.toString());
String result = null;
CMDExecute cmdexe = new CMDExecute();
String[] args = { "/system/bin/cat","/proc/meminfo" };
result = cmdexe.run(args, "/system/bin/");
Log.v(ACTIVITY_TAG,result);
return result;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
android-cpu-net-ram.rar (25个子文件)
time
bin
classes.dex 6KB
com
ray
time
timetest.class 3KB
R$layout.class 376B
R$drawable.class 382B
R$attr.class 322B
R.class 453B
R$string.class 409B
timetest$2.class 1KB
timetest$1.class 766B
CMDExecute.class 2KB
resources.ap_ 10KB
time.apk 15KB
res
drawable-ldpi
icon.png 2KB
drawable-hdpi
icon.png 4KB
values
strings.xml 167B
drawable-mdpi
icon.png 3KB
layout
main.xml 382B
assets
default.properties 362B
gen
com
ray
time
R.java 634B
proguard.cfg 1KB
src
com
ray
time
timetest.java 4KB
CMDExecute.java 733B
.project 840B
.classpath 280B
AndroidManifest.xml 674B
共 25 条
- 1
资源评论
局外狗
- 粉丝: 64
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功