Android Advertising ID compatibility - android

Announcing the Android Advertising ID as "forced" replacement for Android ID, Google did not mention the compatibility concerns.
With iOS, the new advertising identifier was introduced from ~6.0, not downward compatible.
How is this managed with Android now? Do we need a fallback for former Android ID or does each api version support the new identifier? The manual does not cover these concerns.

Requirements
The advertising ID APIs are supported in Google Play services 4.0+
Support for the advertising ID on specific devices is based on their installed versions of Google
Play services
From the example provided,
public void getIdThread() {
Info adInfo = null;
try {
adInfo = AdvertisingIdClient.getAdvertisingIdInfo(mContext);
} catch (IOException e) {
// Unrecoverable error connecting to Google Play services (e.g.,
// the old version of the service doesn't support getting AdvertisingId).
}
}
You need to handle the exception if the user's device is not updated to the required version.

Related

Disable Advertising ID (AAID) collection runtime in Unity Firebase SDK

The new Google policy requires app to not transmit Android Advertising ID when targeting for both children and adults. Is there any option that we can disable it in runtime based on user preference? I found only this doc about disabling the AAID permanently using meta-data in AndroidManifest.xml https://firebase.google.com/docs/analytics/configure-data-collection?platform=android. I'm currently using Unity Firebase SDK at the moment and it does not seem like there's an option for it nor Android native Firebase SDK.
You can find this used in Firebase unity sample MechaHamster in Startup.cs file, here how they used it:
// Start gathering analytic data.
void InitializeAnalytics() {
Firebase.Analytics.FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
// Set the user's sign up method.
Firebase.Analytics.FirebaseAnalytics.SetUserProperty(
Firebase.Analytics.FirebaseAnalytics.UserPropertySignUpMethod,
"Google");
if (CommonData.currentUser != null)
Firebase.Analytics.FirebaseAnalytics.SetUserId(CommonData.currentUser.data.id);
}

Play services vision API in Funtouch OS

I have a Vision API Barcode scanner logic which is based on play-services-vision:17.0.2 to scan barcodes and QR codes. This is working on most phones apart for the users in the China region where play services and stores are disabled.
So, I need to find a way if Vision API is allowed or not and make a switch to either use full-fledged Vision API or fallback to the minimal feature of ZXing library.
For this, I tried googleApiAvailability.isGooglePlayServicesAvailable(activity)
and included com.google.android.gms:play-services-base:17.1.0.
However, after installing the app I am receiving a message that "to open the app Play services and Play store apps are required". How can I address this?
Is there any other way to find out and make the proper switch of features or maybe better ways to handle this?
Thank you...
I found this code snippet in another question and it helped me.
try {
packageManager.getPackageInfo("com.google.android.gms", 0);
// - >Installed
} catch (PackageManager.NameNotFoundException e) {
// -> Not installed
}

how to get the advertising id on the China market (e.g. on MIUI and AliOS)

I currently have code that gets the device identifier (advertising ID) on Google Play enabled and Kindle devices. Now I'm looking for documentation targeting developers that would explain how to get it on other Android forks (similar to Amazon's instructions), esp. on Xiaomi and Alibaba phones made for the local Chinese market.
One resource I could find is by AppsFlyer which is obviously bogus since it states "IMEI and Android ID - Both are necessary for accurate attribution" while the former is disabled since Android 6 (unless you want to prompt the user for a runtime permission) besides other problems with it and the latter is not device unique since Oreo.
Yes, IMEI, Mac address and Android ID are using for the Android market in China. Unity, Vungle and Admob are actually pursuing the Android market. We also heard that other ad networks create a custom Android SDK just for the Chinese market.
Last time I talked to a Chinese developer on the Android market in China was a while back so my info may be outdated. I'll double check tonight.
This isn't the answer I was hoping for, but after further research, the "first and largest independent mobile advertising platform of China", Youmi, does have an open source DeviceInfoUtils class and they do everything AppsFlyer recommended, that is, everything Google is against.
To be specific, with every request, they send: telephonyManager.getDeviceId(); (IMEI on GSM phones), telephonyManager.getSubscriberId() (IMSI on GSM phones), the MAC address, and the ANDROID_ID. Again, the first two of these require prompting the user for allowing the app to "make and manage phone calls" which is super creepy (resulting in bad app ratings and/or denied permissions). The latter two of these used to work but as of Oreo, they are not device unique any more as I mentioned in my question statement.
Update: I have now downloaded Xiaomi's Mimo SDK (ads SDK). Decompiling reveals a class called AdvertisingIdHelper which has only two methods, one to check if the device has Google Play store installed, and the other looks like this:
private static d z(Context paramContext)
{
if (!y(paramContext)) {
return null;
}
try {
d localD = new d();
Intent localIntent = new Intent("com.google.android.gms.ads.identifier.service.START");
localIntent.setPackage("com.google.android.gms");
if (paramContext.bindService(localIntent, localD, 1))
return localD;
} catch (SecurityException localSecurityException) {
com.miui.zeus.a.a.b("stacktrace_tag", "stackerror:", localSecurityException);
return null;
}
return null;
}
What its role is in the overall SDK is unclear but it definitely seems like a way of querying Google's ads ID rather than Xiaomi's alternative ID. If this is for all cases, or only for devices sold outside of China (which does have Google Play services) is again unclear.

Testing which Google Play Services API is running

When updated code containing a deprecated Android API call, it's relatively straightforward to code for each Android version. e.g.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mTonePlayer = new SoundPool.Builder().build();
} else {
mTonePlayer = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
}
But what if something is deprecated in the Google Play Services API? For example LocationServices.GeofencingAPI was recently deprecated and should be replaced by GeofencingClient.
This will depend on the target device running Google Play services version 11.0.0 and isn't necessarily dependent on the Android SDK. So how can I code for both?
e.g.
if (Google Play Services is below version 11.0.0) {
LocationServices.GeofencingApi.removeGeofences(mGoogleApiClient etc
} else {
GeofencingClient gc = LocationServices.getGeofencingClient();
gc.removeGeofences(); etc
}
You can use the checkApiAvailability() method.
Pay attention since the method returns a task that asynchronously checks if specified APIs are available. If one or more aren't available, the task fails with an AvailabilityException.
Otherwise you can isGooglePlayServicesAvailable to verify that Google Play services is installed and enabled on this device, and that the version installed on this device is no older than the one required by this client.

How can I set the notification in android application to update next version

I have upload apk with version 1.0.0.0. I want to upload next version 1.0.0.1.how can I set the notification to inform the user that my application has a newer version available on Google play. Can any one suggest me how to do it?
Found in stackoverflow (duplicated??)
public int getVersion() {
int v = 0;
try {
v = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
} catch (NameNotFoundException e) {
// Huh? Really?
}
return v;
}
I understand your question to be "How does one determine if the play store has a newer version than the one installed".
I don't know of an official way to lookup an app's version in the Play Store. The most common solution I've seen for this requirement is to host the version number on a server somewhere and do a web request to get it.
There's a library at https://code.google.com/p/android-market-api/ that purports to do the Play Store lookup, (among other things) but I don't have any experience with it.
For that you have to configure something called Firebase Cloud Messaging and enable notification. Here is the complete guide on how to.

Categories

Resources