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 ...
随机推荐
- window配置 mysql 详细步骤
1.配置环境变量:右击“我的电脑”-->"高级"-->"环境变量" 3)在(系统变量)path变量(已存在不用新建)添加变量值:G:\MySQL\m ...
- mongodb的db.collection is not function
mongodb的3.0版本之前: 如2.3版本,可以直接使用db调用collection来操作数据 但在3.0版本以上,会报错:db.collection is not a function 3.0版 ...
- 使用GraphHttpClient调用Microsoft Graph接口 - GET
博客地址:http://blog.csdn.net/FoxDave 使用GraphHttpClient类调用Microsoft Graph REST API,你可以使用GET,POST和PATCH请求 ...
- 蓝牙协议分析(10)_BLE安全机制之LE Encryption
1. 前言 前面文章介绍了两种BLE的安全机制:白名单[4]和LL privacy[3].说实话,在这危机四伏的年代,这两种“捂着脸讲话(其它人不知道是谁在讲话,因而不能插话.不能假传圣旨,但讲话的内 ...
- webView 获取内容高度不准确的原因是因为你设置了某个属性
不管是UIWebView 还是 WKWebView 这里 获取js属性 获取高度的方法 我就不一一细说了 ,本文最主要不说这个 ,网上有太多的方法 我最不摘几个 CGFloat webViewHeig ...
- 王者荣耀交流协会第五次Scrum立会
会议时间:2017年10月24号 11:40-12:12,时长32分钟. 会议地点:信息科学与技术学院107教室 昨天工作: 组长使用ZedGraph实现了折线图的生成,基本符合需求,组员们分别完 ...
- mac搭配Nginx服务器常见问题
推流服务器主要是使用了开源的nginx和rtmp模块,网上也有很多资料,不过对有些可能出现的问题没有很好的总结. 安装brew 使用Mac进行开发很久的老司机应该对这个工具很熟悉了.brew是一个第三 ...
- 框架tensorflow2
TensorFlow 2 TensorFlow 激励函数 TensorFlow 添加层: 思考:matmul和multiply两种乘法的区别:http://www.soaringroad.com/?p ...
- [LeetCode&Python] Problem 504. Base 7
Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202&q ...
- 《CSS揭秘》之毛玻璃效果知识点
实现代码: CodePen:毛玻璃效果 Dabblet:毛玻璃效果 HTML: <main> <blockquote> <em>"The only way ...