i want to get Advertising ID for my app, which i have no success.
import androidx.ads.identifier.AdvertisingIdClient;
import androidx.ads.identifier.AdvertisingIdInfo;
public class addUtilsJava extends AsyncTask<Context, String, String> {
static String TAG = "addUtilsJava";
private String getIdThread(Context context) {
AdvertisingIdInfo adInfo = null;
try {
adInfo = AdvertisingIdClient.getAdvertisingIdInfo(context).get();
} catch (Exception exception) {
exception.printStackTrace();
}
if (adInfo != null) {
final boolean isLAT = adInfo.isLimitAdTrackingEnabled();
return adInfo.getId();
}
return null;
}
@Override
protected String doInBackground(Context... contexts) {
return getIdThread(contexts[0]);
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
if (s != null)
Log.d(TAG, s);
}
}
it throw exception that suggesting me androidx.ads.identifier.AdvertisingIdNotAvailableException: No Advertising ID Provider available
. i tried with 2 mobile phone and emulator all with same result.
thanks in advance
ps: i check the solution provided in android doc but it won't work for me https://developer.android.com/training/articles/ad-id
and i rather have a solution that don't require dependency
com.google.android.gms:play-services-ads-identifier
lib, but I'm gettingAdvertisingIdNotAvailableException
when trying to useandroidx
lib. Obviously, the issue is in androidx lib itself. – Cyperaceous