Created
September 23, 2015 03:41
-
-
Save sendtomitesh/412b468d61991703683d to your computer and use it in GitHub Desktop.
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
AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() { | |
@Override | |
protected String doInBackground(Void... params) { | |
AdvertisingIdClient.Info idInfo = null; | |
try { | |
idInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext()); | |
} catch (GooglePlayServicesNotAvailableException e) { | |
e.printStackTrace(); | |
} catch (GooglePlayServicesRepairableException e) { | |
e.printStackTrace(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
String advertId = null; | |
try{ | |
advertId = idInfo.getId(); | |
}catch (NullPointerException e){ | |
e.printStackTrace(); | |
} | |
return advertId; | |
} | |
@Override | |
protected void onPostExecute(String advertId) { | |
Toast.makeText(getApplicationContext(), advertId, Toast.LENGTH_SHORT).show(); | |
} | |
}; | |
task.execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment