Android 开发 知晓各种id信息 获取线程ID、activityID、内核ID
/**
* Returns the identifier of this process's user.
* 返回此进程的用户的标识符。
*/
Log.e(TAG, "Process.myUid() = " + android.os.Process.myTid()); /**
* Returns the identifier of this process, which can be used with
* killProcess and sendSignal.
* 返回此进程的标识符,可用于进程和发送信号。
*/
Log.e(TAG, "Process.myPid() = " + android.os.Process.myPid()); /**
* Returns the identifier of the calling thread, which be used with
* setThreadPriority(int, int).
* 返回调用线程的标识符,该标识符与StTeRead优先级(int,int)。
*/
Log.e(TAG, "Process.myTid() = " + android.os.Process.myTid()); /**
* Returns the thread's identifier. The ID is a positive long generated
* on thread creation, is unique to the thread, and doesn't change
* during the lifetime of the thread; the ID may be reused after the
* thread has been terminated.
* 返回线程的标识符。ID是正长生成的关于线程创建,对于线程是唯一的,并且不会改变。
* 在线程的生存期内,ID可以在线程已被终止。
*/ //返回当前线程的id
Log.e(TAG, "Thread.currentThread().getId() = "
+ Thread.currentThread().getId());
//返回主线程的id
Log.e(TAG, "getMainLooper().getThread().getId() = "
+ getMainLooper().getThread().getId()); //返回当前应用的主线程id
Log.e(TAG,
"((getApplication().getMainLooper()).getThread()).getId() = "
+ ((getApplication().getMainLooper()).getThread())
.getId()); /**
* Return the identifier of the task this activity is in. This
* identifier will remain the same for the lifetime of the activity.
* 返回此活动正在执行的任务的标识符。这个标识符对于活动的生存期将保持不变。
*/
//返回activity任务栈的id
Log.e(TAG, "getTaskId() = " + getTaskId()); /**
* The kernel user-ID that has been assigned to this application;
* currently this is not a unique ID (multiple applications can have the
* same uid).
* 已分配给该应用程序的内核用户ID;这不是一个唯一的ID(多个应用程序可以有相同的UID)。
*/
Log.e(TAG, "getApplicationInfo().uid = " + getApplicationInfo().uid); /**
* The name of the process this application should run in. From the
* "process" attribute or, if not set, the same as packageName.
* 此应用程序应运行的进程的名称。从“进程”属性,或如果没有设置,与PACKAGEName相同。
*/
Log.e(TAG, "getApplicationInfo().processName = "
+ getApplicationInfo().processName); /**
* 得到当前activity的信息
*/
Log.e(TAG, "Activity.toString:"+this.toString()); new Thread(new Runnable() { @Override
public void run() {
//返回当前线程的id
// TODO Auto-generated method stub
Log.e(TAG, "Thread.currentThread().getId() = "
+ Thread.currentThread().getId());
}
}).start();
结果:
2018-08-28 15:00:42.887 29813-29813/com.example.user.demo E/EventBusDemoActivity: Process.myUid() = 29813
2018-08-28 15:00:42.887 29813-29813/com.example.user.demo E/EventBusDemoActivity: Process.myPid() = 29813
2018-08-28 15:00:42.887 29813-29813/com.example.user.demo E/EventBusDemoActivity: Process.myTid() = 29813
2018-08-28 15:00:42.888 29813-29813/com.example.user.demo E/EventBusDemoActivity: Thread.currentThread().getId() = 1
2018-08-28 15:00:42.888 29813-29813/com.example.user.demo E/EventBusDemoActivity: getMainLooper().getThread().getId() = 1
2018-08-28 15:00:42.888 29813-29813/com.example.user.demo E/EventBusDemoActivity: ((getApplication().getMainLooper()).getThread()).getId() = 1
2018-08-28 15:00:42.888 29813-29813/com.example.user.demo E/EventBusDemoActivity: getTaskId() = 113
2018-08-28 15:00:42.888 29813-29813/com.example.user.demo E/EventBusDemoActivity: getApplicationInfo().uid = 10085
2018-08-28 15:00:42.888 29813-29813/com.example.user.demo E/EventBusDemoActivity: getApplicationInfo().processName = com.example.user.demo
2018-08-28 15:00:42.888 29813-29813/com.example.user.demo E/EventBusDemoActivity: Activity.toString:com.example.user.demo.EventBusDemoActivity$1@d500b7a
2018-08-28 15:00:42.888 29813-29832/com.example.user.demo E/EventBusDemoActivity: Thread.currentThread().getId() = 885
Android 开发 知晓各种id信息 获取线程ID、activityID、内核ID的更多相关文章
- android 开发 解码gif图片,获取每帧bitmap
环境:android 4.3 (注意对于android4.4版本解码出来不正确,除了第一帧正确外,其余的都是显示不同的地方) 通用版本见: android 开发对gif解码(适配android 4 ...
- Android开发之多媒体编程之获取图片的副本
使用BitmapFactory的decodeFile()方法获取的Bitmap对象是只读的,无法进行编辑操作 需要进行编辑的话,需要获取到该对象的一个副本 代码如下: import android.a ...
- eclipse android开发,文本编辑xml文件,给控件添加ID后,R.java,不自动的问题。
直接编辑xml文件给控件添加id,不自动更新.原来的id写法:@id/et_tel 然后改写成这样:@+id/et_tel 然后就好了!操`1
- Android开发—已root的手机获取data路径
开发android的时候,尽管手机已经root但是DDMS中还是没有data/data路径怎么办? 可以用cmd命令提示符为逐个文件夹设置权限: 打开cmd,输入 adb shell 回车—> ...
- Android 开发 获取设备信息与App信息
设备信息 设备ID(DeviceId) 获取办法 android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager ...
- android 开发 对图片编码,并生成gif图片
demo场景: 将2张静态的png格式图片组合生成一个gif图片,间隔500毫秒,关键类:AnimatedGifEncoder 如需要解析gif获取每帧的图片,可参考上一篇博客:<android ...
- vue_elementUI_ tree树形控件 获取选中的父节点ID
el-tree 的 this.$refs.tree.getCheckedKeys() 只可以获取选中的id 无法获取选中的父节点ID想要获取选中父节点的id;需要如下操作1. 找到工程下的node_m ...
- Android开发之获取手机SIM卡信息
TelephonyManager是一个管理手机通话状态.电话网络信息的服务类.该类提供了大量的getXxx(),方法获取电话网络的相关信息. TelephonyManager类概述: 可用于訪问有关设 ...
- Android 开发 facebook分享,登陆,获取信息
1 搭建开发环境 1.1 在Facebook官网SDK中,下载4.0.0的SDK包. 1.2 使用Eclipse导入SDK包中的Facebook工程,并添加android-supp ...
随机推荐
- spring注解实现防盗链拦截
首先配置 applicationContext.xml, 添加 <!-- 启用 @AspectJ --> <aop:aspectj-autoproxy /> 新建Java工具类 ...
- git一些有用的命令
更改本地和远程分支的名称 git branch -m old_branch new_branch # Rename branch locally 本地分支改名 git push origin :old ...
- ubuntu 网络配置
检查网络配置命令:ifconfig 一.通过配置文件配置 新手没怎么用过Ubuntu,所以走了不少弯路,网上找了很多方法,大都没对我起到帮助作用,所以把自己的配置方法写一写. Ubuntu上连了两块网 ...
- python实现简单的定时任务
1.首先安装 schedule 模块 命令行安装 pip install schedule pyCharm编辑器安装 File->setting->project:youProject-& ...
- Codeforces1076F. Summer Practice Report(贪心+动态规划)
题目链接:传送门 题目: F. Summer Practice Report time limit per test seconds memory limit per test megabytes i ...
- matlab数学实验--第一章
一. 数据和变量: 省略号(三个英文句点):表示换行 历史指令调用:用方向键上下 数据显示格式: format short ...
- vue 15分钟倒计时
HTML: <span>{{minute}}:{{second}}</span> script: 一 二 // 倒计时 num(n) { return n & ...
- 《C语言程序设计》编程总结汇总
<C语言程序设计>编程总结汇总 院系: 专业年级: 班级名称: 学号: 姓名: 指导教师: 完成时间: 自我评价: 计算机科学与技术专业教研室 2018 年秋季学期 第四周编程总结 题目4 ...
- java初始重点语法
第三章 if基本语法: if(条件){// 表达式 // 代码块 } eg: int a = 10; if(a > 1){ System.out.println("内容"); ...
- AES对称加密和解密(转)
AES对称加密和解密 package demo.security; import java.io.IOException; import java.io.UnsupportedEncodingExce ...