ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

获取GAID得到00000000-0000-0000-0000-000000000000的问题

2022-06-25 09:34:18  阅读:234  来源: 互联网

标签:0000 permission 00000000 000000000000 will API Android


最近大老板查看数据发现有用户上报的GAID有00000000-0000-0000-0000-000000000000的情况。先查代码,发现不是程序写死的常量值,又怀疑是手机的问题,是个例,看了手机的型号,ADVAN出的,印尼最大的手机制造商,那就不像是手机的问题。

程序里是通过AdvertisingIdClient.getAdvertisingIdInfo(context).getId()获取的GAID,然后就查了Google的官方文档,果然发现了端倪。明确说明了用户如果设置了禁止广告追踪,这个getId()就会返回这串0,而且如果适配Android13的话还要多申请一个权限。没有Android12的机器,无法验证这个问题。

下面是AdvertisingIdClient.Info.getId()的说明文档

public String getId ()                                                                          
Retrieves the advertising ID.

Starting from late 2021, on Android 12 devices, when isLimitAdTrackingEnabled() is true, the returned value of this API will be 00000000-0000-0000-0000-000000000000 regardless of the app’s target SDK level.

In early 2022, this change will be applied to all the devices that support Google Play services.

Apps with target API level set to 33 (Android 13) or later must declare the normal permission com.google.android.gms.permission.AD_ID as below in the AndroidManifest.xml in order to use this API.

This permission will be granted when the app is installed.
If this permission is not declared, the returned value will be 00000000-0000-0000-0000-000000000000 starting early 2022.
Until then, to help developers, a warning line is logged if the permission is missing when the app targets API level 33 (Android 13) or higher.
This warning line is under the Log tag AdvertisingIdSettings.

 <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
If you need to prevent the permission from getting merged into your app through dependencies such as SDKs, include the below element in your manifest instead.


<uses-permission android:name="com.google.android.gms.permission.AD_ID"
 tools:node="remove"/>
For apps with target API level set to 32 (Android 12L) or older, this permission is not needed.

See Advertising ID Play Console Help for more details.

 

AdvertisingIdClient.Info.isLimitAdTrackingEnabled()的说明文档

public boolean isLimitAdTrackingEnabled ()                                                                  
Retrieves whether the user has limit ad tracking enabled or not.

When the returned value is true, the returned value of getId() will always be 00000000-0000-0000-0000-000000000000 starting with Android 12.

 

标签:0000,permission,00000000,000000000000,will,API,Android
来源: https://www.cnblogs.com/xlotus/p/16410782.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有