Created
January 6, 2024 07:29
-
-
Save imandaliya/ff0ef24fe1cce74ccf6064d531fbb858 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
private fun getAdsId() { | |
CoroutineScope(Dispatchers.IO).launch { | |
var idInfo: AdvertisingIdClient.Info? = null | |
try { | |
idInfo = AdvertisingIdClient.getAdvertisingIdInfo(applicationContext) | |
} catch (e: GooglePlayServicesNotAvailableException) { | |
e.printStackTrace() | |
} catch (e: GooglePlayServicesRepairableException) { | |
e.printStackTrace() | |
} catch (e: IOException) { | |
e.printStackTrace() | |
} | |
var advertId: String? = null | |
try { | |
advertId = idInfo?.id | |
} catch (e: NullPointerException) { | |
e.printStackTrace() | |
} | |
Log.d("_TAG_", "getAdsId:104 => $advertId") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment