Android: how to manually set the network via terminal

If we want manually set the network in Android, for example 2G or 3G, then we can use a simple command via the terminal or via adb.

For the Motorola Stock Rom we can use this command:

am broadcast -a com.android.phone.CHANGE_NETWORK_MODE --ei networkMode *VALUE*

For the AOSP Rom we can use this command:

am broadcast -a com.android.internal.telephony.MODIFY_NETWORK_MODE --ei networkMode *VALUE*

VALUE is one of these:

0: WCDMA preferred
1: GSM only
2: WCDMA only
3: GSM auto (PRL)
3: CDMA auto (PRL)
4: CDMA only
5: EvDo only
6: GSM/CDMA auto (PRL)
7: LTE/CDMA auto (PRL)
8: LTE/GSM auto (PRL)
9: LTE/GSM/CDMA auto (PRL)
10: LTE only

Source: pabreu

Tags: