Last active
February 8, 2018 16:08
-
-
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)
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
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