So i created a class to retrieve the Google advertising id of the users device. i an still however getting a null pointer. i followed this question
However it still didn't work. here is my class code
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
public class GAID extends AppCompatActivity {
public String mUserId;
public GAID() {
new Thread(new Runnable() {
public void run() {
try {Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext());
mUserId = adInfo.getId();
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gaid);
}
public String getGAID() {
return mUserId;
}
I am dealing with the same issue. i found a solution but it is not perfect.