Created
August 15, 2019 10:11
-
-
Save pavelsust/299667b5f271958b8575bc600c5faf39 to your computer and use it in GitHub Desktop.
get device id for facebook ad test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class customTask extends AsyncTask<Void, String, String> { | |
@Override | |
protected void onPreExecute() { | |
super.onPreExecute(); | |
} | |
@Override | |
protected String doInBackground(Void... voids) { | |
AdvertisingIdClient.Info adInfo = null; | |
try { | |
adInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext()); | |
} catch (IOException e) { | |
// ... | |
} catch (GooglePlayServicesNotAvailableException e) { | |
e.printStackTrace(); | |
} catch (GooglePlayServicesRepairableException e) { | |
e.printStackTrace(); | |
} | |
String userId = adInfo.getId(); | |
return userId; | |
} | |
@Override | |
protected void onPostExecute(String s) { | |
super.onPostExecute(s); | |
Log.d("FACEBOOK_ID", "" + s.toString()); | |
} | |
} | |
and it will execute like this | |
new customTask().execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment