Android onSignalStrengthsChanged – LTE Strength Measurement

Android onSignalStrengthsChanged

In this tutorial I would show how to measure the signal strengths in Android. Since Android is a mobile operating system, therefore measuring signal strengths from device itself would be a very easy task. Android onSignalStrengthsChanged is a method in Android PhoneStateListener class which observes the changes in telephony states of a device. In my previous tutorials I utilized the power of Android PhoneStateListener class to determine the changes in message waiting indicator, service state, data activity and also to monitor the change in cell info. If you wish to read the full series, links are below:

1) Android PhoneStateListener Example
2) Android onDataConnectionStateChanged – Detect Network Type
3) Android onSignalStrengthsChanged – LTE Strength Measurement

To listen the change in signal strengths a flag PhoneStateListener.LISTEN_SIGNAL_STRENGTHS is used in the listen method of TelphonyManager class. By using this flag we will start getting the callbacks in onSignalStrengthsChanged(SignalStrength signalStrength) method whenever the signal strength of network changes.

No Permissions needed

Now the interesting part here is that, to use the Android onSignalStrengthsChanged method we don’t need to add any permissions in our manifest. I tested this on a Kitkat 4.4.4 device.

Lets start with PhoneStateListener Activity:

As you can see in the above class, a custom Android PhoneStateListener is used to capture the updates of signal strengths with the help of TelephonyManager class. as soon as the listener is registered, we start receiving callbacks in Android PhoneStateListener onSignalStrengthsChanged method.

Android onSignalStrengthsChanged LTE measurement

LTE (Long-Term Evolution) is a new emerging standard for wireless communication. LTE is an upgrade for both GSM/UMTS and CDMA2000 Networks. Here the good part is, android supports LTE standard. With the help of PhoneStateListener and Android onSignalStrengthsChanged method we can measure LTE signal strengths. In this Android onSignalStrengthsChanged – LTE Strength Measurement tutorial I would show how to measure the signal strength for LTE network by using the Java Reflection APIs. Lets define the custom PhoneStateListener:

Before moving forward let me give a brief intro to Java Reflection API. Reflection API is used to examine or modify the run-time behavior of any application in running in virtual machine (DVM or ART). Since this is a very powerful API, it is advised to use this only if you know what you are doing. To read more about reflection API, please go here. Coming back to this tutorial, here we are using the reflection APIs to invoke following methods which are not included in Android APIs:

  1. getLteSignalStrength – Returns LTE signal strength
  2. getLteRsrp – Returns LTE Reference Signal Received Power
  3. getLteRsrq – Returns LTE Reference Signal Received Quality
  4. getLteRssnr – Returns LTE rssnr
  5. getLteCqi – Returns LTE Channel Quality Indication

Android Signal Strength

Although if we go by standard Android APIs, whenever Android onSignalStrengthsChanged method is invoked an object of SignalStrength is passed as an argument. As its shown in the above code, with this object we can determine the type of signal being receiving on device. It could be any type of network like GSM, CDMA or EVDO, hence one can get signal strength as well. Hope this helped you out, if it did please share it with your friends.

About Mohit Gupt

An android enthusiast, and an iPhone user with a keen interest in development of innovative applications.

Leave a comment

Your email address will not be published. Required fields are marked *

5 thoughts on “Android onSignalStrengthsChanged – LTE Strength Measurement