[Root Required] Change mobile network mode programmatically
So for your convenience, the APK can be directly downloaded at https://github.com/Hzj-jie/android-mobile-network-mode/raw/master/android-mobile-network-mode-release.apk.
This app installs three items in app menu, "Enable 2G", "Enable 3G" and "Enable 4G". Each one does its job and quit. i.e. Enable 2G, 3G or 4G. Please refer to the first screenshot.
I am using this with https://play.google.com/store/apps/details?id=org.gemini.init, and change network preference according to the location. Ex.
https://github.com/Hzj-jie/android-init/blob/master/sample/auto-network.sh
You can also manually set the the preferred network type by using an intent,
mobile-network-mode://org.gemini.mobile-network-mode/#{TYPE}
The type can be found in https://android.googlesource.com/platform/frameworks/base/+/master/telephony/java/com/android/internal/telephony/RILConstants.java#136.