I can use android.settings.WIRELESS_SETTINGS
to turn on wireless and Bluetooth,but what should I use to turn on mobile internet?
Intents are used to signal to the Android system that a certain event has occurred. Intents often describe the action which should be performed and provide data upon which such an action should be done. For example, your application can start a browser component for a certain URL via an intent.
Open your phone's Settings app. Internet. Next to your carrier, tap Settings . Turn Mobile data on or off.
Turn off Smart Network Switch – If you have this setting on your mobile phone, and if it is turned on, your mobile phone is connected to the cellular network automatically when the Wi-Fi connection is weak. Just turn this setting off, and check if the problem persists.
From Lollipop there is restrictions in enabling mobile data programatically.
Use this code to intent to Mobile Data Usage where you can TurnOn/Off Mobile Data :
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$DataUsageSummaryActivity"));
startActivity(intent);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With