Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mobile Network Settings in Android 4.1

My app should open Mobile Network Settings activity. Everything works fine except devices with Android 4.1 which crash after attempt to open Settings

Intent intent = new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS);
final ComponentName cName = new ComponentName("com.android.phone", "com.android.phone.Settings");
intent.setComponent(cName);
startActivity(intent);

Stack trace after crashing:

java.lang.SecurityException: Permission Denial: starting Intent { act=android.settings.DATA_ROAMING_SETTINGS cmp=com.android.phone/.Settings } from ProcessRecord{41b83198 ...

Any ideas? Could it be because of the manifest?

UPDATE:

Seem that the problem was solved here: Android - Mobile network settings menu (Jelly Bean)

The thing is to change "com.android.phone.Settings" to "com.android.phone.MobileNetworkSettings"

like image 945
Alex Avatar asked Aug 27 '12 18:08

Alex


1 Answers

I think you have to try

Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS);
startActivity(intent);

This thing is working for me in android 4.1.2, might be they fixed this issue in 4.1.2

like image 112
AJit Avatar answered Oct 13 '22 07:10

AJit