How to enable/disable 3G/2G in Android SDK
Asked Answered
S

2

6

I am just wondering how to enable/disable 3G/2G using the Android SDK and not just intenting to the 3G settings page. Thanks. Also is there a way to do the same thing, but with GPS. Thanks!

Submariner answered 29/5, 2011 at 21:16 Comment(0)
J
5

There is no exported to the SDK functionality to switch between 2G and 3G. For a given device you could probably figure out the private functionality, but it wouldn't work unless the app was signed with the system key.

You can disable the radios though, by turning on airplane mode.

And you might be able to make a shortcut to open the appropriate settings activity directly, instead of going through a few levels of menus to get there.

If you make your own build, you can presumably add the capability you really want, but that's likely not useful to anyone but yourself.

Edit: further detail - to understand how it works, look at the settings menu code (default version, a given device will differ):

http://android.git.kernel.org/?p=platform/packages/apps/Phone.git;a=blob;f=src/com/android/phone/Settings.java;hb=HEAD

Edit: AOSP is no longer served from kernel.org. A browsable mirror of the current phone repository is at https://github.com/android/platform_packages_apps_phone however due to evolution of code organization there is no longer a Settings.java there. One might either use git to reconstruct the version above from this repository, or else try to figure out where the code has migrated to in current releases.

You would need to find out the implementation specific set of NT_MODE_ constants you wish to toggle between. And you need to be able to write to secure settings, which requires being signed with the system key. Unless it's a custom build, you probably don't have access to that.

Jerad answered 29/5, 2011 at 21:45 Comment(3)
I mean can you enable/disable 3G like for example using a togglebutton?Submariner
Thanks a bunch now I get what I have to do! Thanks a bunch.Submariner
Good luck... you will need it. This is deeply in not recommended territory.Jerad
A
4

You cannot enable or disable any of these from an SDK application.

Actualize answered 29/5, 2011 at 21:44 Comment(2)
@Ciehanski Apps: As Mr. Stratton notes, you can force the radios off with airplane mode. However, this does not disable the radios. Nor does toggling airplane mode enable previously disabled radios -- for example, if the user has disabled GPS, there is nothing you can do to enable it. "Enable" and "disable" have very specific meanings in Android, and airplane mode has nothing to do with them.Actualize
@Ciehasnki Commonsware is absolutely correct, there is no SDK functionality to do this. What is talked about in the edit to my answer is platform application capability, which is NOT part of the SDK, and not deployable except by the creator of a custom build who holds the system certificate and knows the private internal details of that build.Jerad

© 2022 - 2024 — McMap. All rights reserved.