Java Code Examples for com.google.android.gms.ads.identifier.AdvertisingIdClient#getAdvertisingIdInfo()

The following examples show how to use com.google.android.gms.ads.identifier.AdvertisingIdClient#getAdvertisingIdInfo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IDFA.java    From react-native-idfa with MIT License 6 votes vote down vote up
@ReactMethod
public void getIDFA(Promise promise) {
    try {
        AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(this.getReactApplicationContext());

        String adId = null;
        if (adInfo.isLimitAdTrackingEnabled()) {
            adId = "";
        } else {
            adId = adInfo != null ? adInfo.getId() : "";
        }

        promise.resolve(adId);
    } catch (Exception e) {
        promise.reject(e);
    }
}
 
Example 2
Source File: FetchAdvertisingInfoTask.java    From openlocate-android with MIT License 5 votes vote down vote up
@Override
protected Void doInBackground(Void... params) {
    try {
        info = AdvertisingIdClient.getAdvertisingIdInfo(context);
    } catch (IOException
            | GooglePlayServicesNotAvailableException
            | GooglePlayServicesRepairableException e) {
        Log.e(TAG, e.getMessage() != null ? e.getMessage() : "Failed to get ad id.");
    }

    return null;
}
 
Example 3
Source File: hb.java    From letv with Apache License 2.0 5 votes vote down vote up
private Info n() {
    Info info = null;
    try {
        info = AdvertisingIdClient.getAdvertisingIdInfo(hn.a().c());
    } catch (Exception e) {
        ib.b(a, "GOOGLE PLAY SERVICES ERROR: " + e.getMessage());
        ib.b(a, "There is a problem with the Google Play Services library, which is required for Android Advertising ID support. The Google Play Services library should be integrated in any app shipping in the Play Store that uses analytics or advertising.");
    }
    return info;
}