1

suggest me source code. My source code is

TelephonyManager manager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
if(manager.getNetworkType()==TelephonyManager.NETWORK_TYPE_UMTS){
      // tx.setText("Edge"); 
      //int enabled = Settings.Secure.getInt(getContentResolver(),
                   // "preferred_network_mode", -1);
     cm.setNetworkPreference(TelephonyManager.NETWORK_TYPE_EDGE);
     cm.startUsingNetworkFeature(TelephonyManager.NETWORK_TYPE_EDGE, "Deneme"); 
}                       
ngrashia
  • 9,869
  • 5
  • 43
  • 58
  • I gave an answer to a similar question here: http://stackoverflow.com/a/31710353/5146702 – pulce Jul 29 '15 at 20:25

1 Answers1

0

You cannot do this as it is a restricted setting. You need a special permission, to change it. Take a look at this post.

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.

ngrashia
  • 9,869
  • 5
  • 43
  • 58