1
我在我的應用程序中使用廣告ID,代碼工作正常我在運行Android Nouget 7.1.2的設備上測試了它。你能指出我應該添加什麼來讓它在Nouget中嗎?Google廣告ID在Nouget上返回空值
private static void getAdvertisingID() {
AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
AdvertisingIdClient.Info idInfo = null;
try {
idInfo = AdvertisingIdClient.getAdvertisingIdInfo(_context);
if (idInfo.isLimitAdTrackingEnabled()){ // check if user has opted out of tracking
Log.i("NetworkStateChangeReceiver","Not Found");
return "did not found GAID... sorry";
}
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
} catch (GooglePlayServicesRepairableException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
String advertId = null;
try{
advertId = idInfo.getId();
}catch (Exception e){
e.printStackTrace();
}
return advertId;
}
@Override
protected void onPostExecute(String advertId) {
Log.i("NetworkStateChangeReceiver","Found "+advertId);
UtilHelper.setDeviceIDFA(advertId);
}
};
task.execute();
}