当前位置:网站首页>Get the Google Advertising ID as a unique identifier
Get the Google Advertising ID as a unique identifier
2022-07-30 14:35:00 【Internet Red Panda】
一、背景
在Android程序中,有时候我们APPA unique identification code is required,to distinguish users.在Androidprovided in the systemAndroidId,但AndroidId有时候会为null,同时root手机用户,androidid可以改变.所以AndroidIdNot as a unique identifier.
对于Google推荐使用Google Advertising ID,通过Google Service可以获取Google Advertising ID(如果没有Google ServiceI can't go backGoogle Advertising ID).
二、代码实现
/** * This method is time consuming,Cannot be called on the main thread */
public static String getGoogleAdId(Context context) throws Exception {
if (Looper.getMainLooper() == Looper.myLooper()) {
return "Cannot call in the main thread, You must call in the other thread";
}
AdvertisingIdClient.Info idInfo = null;
try {
idInfo = AdvertisingIdClient.getAdvertisingIdInfo(ctx);
} catch (IOException e) {
e.printStackTrace();
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
} catch (GooglePlayServicesRepairableException e) {
e.printStackTrace();
}
String adid = null;
try {
if (idInfo != null) {
adid = idInfo.getId();
}
} catch (NullPointerException e) {
e.printStackTrace();
}
return adid;
}
边栏推荐
- Allure Advanced - Dynamically Generate Report Content
- The use of ccs software (app software that makes money reliably)
- LeetCode二叉树系列——144.二叉树的最小深度
- Why do software testing have to learn automation?Talk about the value of automated testing in my eyes
- #第九章 子查询课后习题
- HCIP(第十五天) —— 交换机(一)
- 机器学习在竞赛和工业界应用区别
- Web3创始人和建设者必备指南:如何构建适合的社区?
- 网站添加能换装可互动的live 2d看板娘
- 3年软件测试经验面试要求月薪22K,明显感觉他背了很多面试题...
猜你喜欢

“12306” 的架构到底有多牛逼

我为何从开发人员转做测试,3年软件测试工程师,带你聊聊这其中的秘辛

ROS 导航

Interface automation framework, lm-easytest beta version released, use it quickly~

跳槽前,把自己弄成卷王

Huawei's 7-year-experienced software testing director, gives some advice to all friends who want to change careers to learn software testing

Data Middle Office Construction (5): Breaking Enterprise Data Silos and Extracting Data Value

No-code development platform application visible permission setting introductory tutorial

手把手教你写让人眼前一亮的软件测试简历,收不到面试邀请算我输

Classic test interview questions set - logical reasoning questions
随机推荐
LeetCode二叉树系列——144.二叉树的最大深度
近两年激光雷达运动物体分割论文阅读小结
双碳目标下:农田温室气体排放模拟
MQTT网关读取西门子PLC数据传输到阿里云平台案例教程
Flask Framework - Sijax
The truth of the industry: I will only test those that have no future, and I panic...
There is a risk of water ingress in the battery pack tray and there is a potential safety hazard. 52,928 Tang DMs are urgently recalled
简单理解精确率(Precision),召回率(Recall),准确率(Accuracy),TP,TN,FP,FN
EasyV数字孪生流域|宁波智慧水利整体智治综合应用
数字信号处理课程实验报告(数字信号处理需要什么基础)
Simple understanding of Precision, Recall, Accuracy, TP, TN, FP, FN
[VMware virtual machine installation mysql5.7 tutorial]
How to use Databricks for data analysis on TiDB Cloud | TiDB Cloud User Guide
LeetCode二叉树系列——515.最每个树行中找最大值
从实例来看DAO:权力分散的伟大尝试
Six-faced ant financial clothing, resisting the bombardment of the interviewer, came to interview for review
OFDM Sixteen Lectures 3- OFDM Waveforms
记面试外包公司的一次经历,到底该不该去?
3 years of software testing experience, the interview requires a monthly salary of 22K, obviously he has memorized a lot of interview questions...
(HR面试)最常见的面试问题和技巧性答复