当前位置:网站首页>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;
}
边栏推荐
- 跳槽前,把自己弄成卷王
- Conversion between pytorch and keras (the code takes LeNet-5 as an example)
- PyQt5快速开发与实战 9.1 使用PyInstaller打包项目生成exe文件
- Redis6.0 source code learning (5) ziplist
- 00后测试员摸爬滚打近一年,为是否要转行或去学软件测试的学弟们总结出了以下走心建议
- BI-SQL丨WHILE
- CF1677E Tokitsukaze and Beautiful Subsegments
- 2022年,目前大环境下还适合转行软件测试吗?
- 获取Google Advertising ID作为唯一识别码
- Teach you how to write an eye-catching software testing resume, if you don't receive an interview invitation, I will lose
猜你喜欢

Start learning C language

如何在 TiDB Cloud 上使用 Databricks 进行数据分析 | TiDB Cloud 使用指南

为什么做软件测试一定要学自动化?谈谈我眼中自动化测试的价值

开源工具推荐:高性能计算辅助工具MegPeak
![[VMware virtual machine installation mysql5.7 tutorial]](/img/eb/4b47b859bb5695c38d48c8c01c9da0.png)
[VMware virtual machine installation mysql5.7 tutorial]

Desktop Software Development Framework Awards

(HR面试)最常见的面试问题和技巧性答复

LeetCode二叉树系列——145.二叉树的后序遍历

2022年,目前大环境下还适合转行软件测试吗?

Data Middle Office Construction (5): Breaking Enterprise Data Silos and Extracting Data Value
随机推荐
双碳目标下:农田温室气体排放模拟
sql中ddl和dml(sql与access的区别)
什么是缺陷分析?一篇文章带你了解,测试工程师必备技能
redis6.0 源码学习(五)ziplist
No-code development platform application visible permission setting introductory tutorial
Eclipse connects to SQL server database "recommended collection"
Simple understanding of Precision, Recall, Accuracy, TP, TN, FP, FN
5. DOM
Flask Framework - Sijax
从实例来看DAO:权力分散的伟大尝试
接口自动化框架,lm-easytest内测版发布,赶紧用起来~
Androd 跳转到google应用市场
CF1320E Treeland and Viruses
Understand the Chisel language. 29. Chisel advanced communication state machine (1) - communication state machine: take the flash as an example
Skywalking入门
新时代背景下智慧城市的建设与5G技术有何关联
Shell变量与赋值、变量运算、特殊变量、重定向与管渠
时间序列的数据分析(四):STL分解
LeetCode二叉树系列——144.二叉树的最小深度
CF338E Optimize!