tags:

views:

105

answers:

2

Hi Everyone,

I just want to ask you if you anyone knows how to change the Setting available in: Settings->Wireless Settings->Mobile Network from code or Setting: Settings->Wireless Settings->Mobile Network Settings->Network operators->Select Automatically?

I had been unable to find a property that match this setting in the Settings.System / Settings.Secure classes.

Is there any alternative way to "turn on/off" the MOBILE connectivity ? The reason I need to solve this is to workaround the bug occur during transitioning from WIFI to MOBILE that do not enable CELL data automatically.

Thanks in advance,

Pablo

A: 

I think support for this sort of thing(changing settings from code) was removed/deprecated in the newer versions of the SDK; it is not advisable. What I've said is based on Dan Morill's Blog titled: Future Proofing your Android Apps

Eitherways, generally, you would write:

Settings.System.putString(getContentResolver(), <Settings.System.CONST>, <value>);

and have the following permission in your maifest: android.permission.WRITE_SETTINGS The List of Settings.System.CONST can be found in the official documentation: see here

Samuh
A: 

Hi again, I didnt know about the article you mention but as mentioned before there is nothing available in Settings.system or Settings.Secure about what I am trying to achieve. Any suggestion about how to perform this ?

Pablo Perotti
I am not sure about what property maps to setting of Network operators, even if it is allowed which I seriously doubt. However, I think you should be able to turn Wifi off by using the WifiManager class.wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);wifiManager.setWifiEnabled(false);
Samuh
Also, this thread might be useful..http://groups.google.com/group/android-discuss/browse_thread/thread/1bc1337bc764a51a
Samuh
http://stackoverflow.com/questions/763972/google-android-how-to-figure-out-if-3g-and-2g-is-turned-on
Samuh