7

I am trying to write a widget so I can enable/disable LTE on my Verizon Galaxy Nexus without going deep into the settings menu to do so. However, I have yet to figure out how to determine if LTE is actually turned on. I can determine if my phone currently has a LTE signal or an EVDO signal, but not if LTE is enabled when the phone has an EVDO signal.

Does anyone have some suggestions on where to look in the Android Developers Reference? I have tried TelephonyManager & ConnectivityManager but so far neither is working for me.

Jeff
  • 688
  • 1
  • 13
  • 30
smccloud
  • 390
  • 2
  • 7
  • 16

2 Answers2

0

Have you tried this?

TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService( Context.TELEPHONY_SERVICE );
boolean isLTEConnected = telephonyManager.getNetworkType() == TelephonyManager.NETWORK_TYPE_LTE;
Jason Robinson
  • 31,005
  • 19
  • 77
  • 131
  • I currently have LTE enabled on my phone but am on a CDMA connection, that returns false. Thats what I got stuck on earlier. It "should" work if one thinks logically, but it only works if you have an active LTE connection. Directly from the Android Developer Reference "public int getNetworkType () Returns a constant indicating the radio technology (network type) currently in use on the device for data transmission." – smccloud Jun 11 '12 at 20:10
  • You may check the [`ConnectivityManager`](http://developer.android.com/reference/android/net/ConnectivityManager.html), using a combination of `getNetworkInfo(ConnectivityManager.TYPE_MOBILE)` and `NetworkInfo.getTypeName()`, though I'm not sure if that'll get you what you want. – Jason Robinson Jun 11 '12 at 20:28
  • NetworkInfo.getTypeName() returns "MOBILE" or "WIFI". One would think Google would add proper support for LTE like they did WiMAX since WiMAX is dead and even Sprint switched to LTE. Also, ConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).toString() returns "06-11 15:33:32.239: W/LTE Toggle Widget(12811): NetworkInfo: type: mobile[CDMA - eHRPD], state: CONNECTED/CONNECTED, reason: simLoaded, extra: VZWINTERNET, roaming: false, failover: false, isAvailable: true" in LogCat. – smccloud Jun 11 '12 at 20:31
0

See this link : http://developer.android.com/reference/android/telephony/TelephonyManager.html and on this you can find an example : http://developer.android.com/training/efficient-downloads/connectivity_patterns.html

You have to use the following function : TelephonyManager.getNetworkType()

Guillaume
  • 8,741
  • 11
  • 49
  • 62
  • I am using TelephonyManager.getNetworkType(), but it returns CDMA even if LTE is enabled but I have only a CDMA data connection. To me it makes no sense that there isn't an easy way to determine if LTE is enabled (even if it isn't the current active connection). Directly from the Android Developer Reference "public int getNetworkType () Returns a constant indicating the radio technology (network type) currently in use on the device for data transmission." – smccloud Jun 11 '12 at 20:12
  • Yes, which so far I haven't figured out how to get (unless I just overlooked it which is possible). – smccloud Jun 11 '12 at 20:17
  • Thought ConnectivityManager.getNetworkPreference() might be what I need but it returns "1" with LTE on & LTE off so that isn't it. – smccloud Jun 11 '12 at 20:23
  • It's weird, because I pretty sure that if you put off the LTE, the preferred network change, because I think it's the same way than you put off/on the 3G. I haven't a LTE phone, but put off and on the LTE and watch in phone info (*#*#4636#*#* on the phone dial > Phone Info) – Guillaume Jun 12 '12 at 16:09
  • For some reason #*#4636#*# doesn't work on my Galaxy Nexus. Maybe it doesn't work on ICS? – smccloud Jun 12 '12 at 17:48
  • Got it working, its *#*#4636#*#* and with LTE on and off it shows "GSM/CDMA auto (PRL)" for the prefered network. Must be due to the fact that it uses GSM for LTE and CDMA for 3G/1x? – smccloud Jun 12 '12 at 18:29
  • It's because I forgot an * at the end – Guillaume Jun 12 '12 at 19:24
  • No, it removes the leading and trailing *. Did it to me too.... It is "*#*#4636#*#**" – smccloud Jun 12 '12 at 19:57
  • Yeah, this one work one my phone, I'm pretty it works on yours too – Guillaume Jun 13 '12 at 11:52
  • Yep, that worked. Unfortunately it still shows "GSM/CDMA auto (PRL)" as my preferred network with LTE on & off :( – smccloud Jun 13 '12 at 15:40
  • So, I'm sorry but I don't another method, to find something like that. – Guillaume Jun 14 '12 at 11:19
  • No problem. I haven't given up yet, just thinking about it more. – smccloud Jun 14 '12 at 14:39