Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intent used to turn on Mobile data?

I can use android.settings.WIRELESS_SETTINGS to turn on wireless and Bluetooth,but what should I use to turn on mobile internet?

like image 677
Ryan Avatar asked Jul 14 '12 14:07

Ryan


People also ask

What is Intent data Android?

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.

How do I get my mobile data to turn on?

Open your phone's Settings app. Internet. Next to your carrier, tap Settings . Turn Mobile data on or off.

Why does my phone automatically turn on mobile data?

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.


1 Answers

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);
like image 168
Sriram C G Avatar answered Oct 27 '22 15:10

Sriram C G