Question

I am having trouble getting the RSSI or network strength on Android 4.0+. The current method i use works on any version of android below though.

Here is what i am attempting...


ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = cm.getActiveNetworkInfo();
    if (netInfo != null && netInfo.isConnected()) {
    signalStrengthTextView = (TextView) view.findViewById(R.id.signalStrengthTextView);
    signalStrengthListener = new SignalStrengthListener();  
    ((TelephonyManager)getSystemService(TELEPHONY_SERVICE)).listen(signalStrengthListener,SignalStrengthListener.LISTEN_SIGNAL_STRENGTHS);
    int SIGNAL_STRENGTH_VALUE = 0;
    try {
        SIGNAL_STRENGTH_VALUE = Integer.parseInt(signalStrengthTextView.getText().toString());
    } catch(NumberFormatException nfe) {
}

The value always returns as 99 and not the correct RSSI. Any help would be awesome!

Était-ce utile?

La solution

Not that I'm expert on telephony API. Here are the values which do not update until they stray out of the last range.

     SIGNAL_STRENGTH_NONE_OR_UNKNOWN (99)
     SIGNAL_STRENGTH_GREAT (16-32)
     SIGNAL_STRENGTH_GOOD (8-15)
     SIGNAL_STRENGTH_MODERATE (4-7)
     SIGNAL_STRENGTH_POOR (0-3)

Hope this helps a little... not a solution but could be helpful.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top