dependencies { implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0' } import com.google.android.gms.ads.identifier.AdvertisingIdClient; import com.google.android.gms.ads.identifier.AdvertisingIdClient.Info; try { Info advertisingInfo = AdvertisingIdClient.getAdvertisingIdInfo(context); String adId = advertisingInfo.getId(); } catch (Exception e) { } import com.google.android.gms.common.GooglePlayServicesNotAvailableException; import com.google.android.gms.common.GooglePlayServicesRepairableException; import com.google.android.gms.common.GooglePlayServicesNotAvailableException; try { int isLimitAdTrackingEnabled = AdvertisingIdClient.getAdvertisingIdInfo(context).isLimitAdTrackingEnabled(); if (isLimitAdTrackingEnabled == 0) { } else { } }


上一篇:
下一篇:
切换中文