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 ...
随机推荐
- Linux下实现ssh免密认证
添加域名映射 配置ssh免密登陆 拷贝master服务器公钥至本机 验证master服务器ssh免密登录其余服务器 添加域名映射 打开hosts文件 Vim /etc/hosts 添加域名对象 配置s ...
- leetcode python 030 Substring with Concatenation of All Words
## 您将获得一个字符串s,以及一个长度相同单词的列表.## 找到s中substring(s)的所有起始索引,它们只包含所有单词,## eg:s: "barfoothefoobarman&q ...
- python私有属性和私有方法
私有属性和私有方法 01. 应用场景及定义方式 应用场景 在实际开发中,对象 的 某些属性或方法 可能只希望 在对象的内部被使用,而 不希望在外部被访问到 私有属性 就是 对象 不希望公开的 属性 私 ...
- design
type Config struct { Item lock } func (*Config) getItem(){ } func (*Config) SetItem(){ } channel : - ...
- nginx——Nginx 防爬虫优化
if ($http_user_agent ~* "qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediap ...
- the principle of redbalck tree
- CMD命令,动态执行存储或DML命令
--exec master..xp_cmdshell CMD命令 --EXECUTE sys.sp_sqlexec 执行存储 --EXEC sp_executesql 执行DML语句
- 问题 Duplicate entry '0' for key 'PRIMARY'
今天使用了触发器,在一个表中执行增删改操作,然后在另一个表中执行相应的记录时,出现了这个问题 其实这个问题应该算是细节问题,有两种情况: 1.就是在插入数据的时候将id设置为not nul但是在插入数 ...
- python学习之路06——字符串
字符串 1.概念 字符串就是由若干个字符组成的有限序列 字符:字母,数字,特殊符号,中文 表示形式:采用的单引号或者双引号 注意:字符串属于不可变实体 2.创建字符串 str1 = "hel ...
- 几种数据格式的处理 - Python
1. CSV数据 import csv csvfile = open('data_text.csv','rb') reader = csv.reader(csvfile) # 返回数据为列表类型 # ...