Skip to content

Instantly share code, notes, and snippets.

@gbzarelli
Last active February 8, 2018 16:08
Show Gist options
  • Save gbzarelli/6610c0acce93fb4d3abccf15d0cb8cd8 to your computer and use it in GitHub Desktop.
Save gbzarelli/6610c0acce93fb4d3abccf15d0cb8cd8 to your computer and use it in GitHub Desktop.
Como saber se os dados móveis está ativo nas configurações (How to tell if ‘Mobile Network Data’ is enabled or disabled)
fun getMobileDataEnabled(contentResolver: ContentResolver):Boolean{
return 1 == Settings.Global.getInt(contentResolver, "mobile_data", 1)
}
fun hasIccCard(context:Context):Boolean{
val systemService = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
return systemService.hasIccCard()
}
fun startScreenDataMobile(context:Context){
val intent = Intent()
intent.component = ComponentName("com.android.settings", "com.android.settings.Settings\$DataUsageSummaryActivity")
context.startActivity(intent)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment