Created
August 17, 2013 10:26
-
-
Save slightfoot/6256258 to your computer and use it in GitHub Desktop.
Listening for GSM signal strength changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void registerListenForSignalStrengths(Context context) | |
{ | |
TelephonyManager tm = (TelephonyManager)context.getSystemService(TELEPHONY_SERVICE); | |
tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); | |
} | |
public void unregisterListenForSignalStrengths(Context context) | |
{ | |
TelephonyManager tm = (TelephonyManager)context.getSystemService(TELEPHONY_SERVICE); | |
tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); | |
} | |
private PhoneStateListener mPhoneStateListener = new PhoneStateListener(){ | |
@Override | |
public void onSignalStrengthsChanged(SignalStrength signalStrength) | |
{ | |
if(signalStrength.isGsm()){ | |
Log.d("SIGNAL STRENGTH", String.valueOf(signalStrength.getGsmSignalStrength())); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment