sandeep sandeep - 2 months ago 15
Android Question

How can I launch mobile network settings screen from my code

I want to launch mobile network settings screen, so that user can enable/disable 3g or data connection. Can anybody tell me which intent I need to use for starting activity.
I used

Intent in = new Intent(android.provider.Settings.ACTION_NETWORK_OPERATOR_SETTINGS )


and

Intent in = new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS ).


but both of these didn't work.

Answer

They won't work because there was a bug that was fixed I think in 2.3.

See https://review.source.android.com/#/c/22229/

You can bypass this using (for NETWORK_OPERATOR_SETTINGS)

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.android.phone", "com.android.phone.NetworkSetting");
startActivity(intent);

Replace NetworkSetting with Settings for DATA_ROAMING_SETTINGS

there's another similar solution described in Error opening mobile network settings menu

UPDATE

I recently tested this and it seems that this workaround is still necessary up to API level 15. Since API level 16 the intents in the question seem to work correctly.

Comments