"Immediate" phone signal strength

Put your problem here if it does not fit any of the other categories.

"Immediate" phone signal strength

Postby alt236 » Wed Apr 13, 2011 3:12 pm

Hi All,

I am trying to find a way to get an "instant" signal strength reading. By instant I mean that I would like to have a function which when called it would return the signal strength, even if there is a delay involved.

The current implementation I have is capturing the onSignalStrengthsChanged via a PhoneStateListener but the event is fired after my GUI is updated.

The relevant code is below. It is located in a different class than the main activity. Let me know if I missed anything, but it should be the standard implementation):
Code: Select all
private final String NO_SIGNAL_STRENGTH = "?";
private String CurrentPhoneSignalStrength = NO_SIGNAL_STRENGTH;

   public String getCurrentSignalStrength(){
      return CurrentPhoneSignalStrength;      

   private class MyPhoneStateListener extends PhoneStateListener
      public void onSignalStrengthsChanged(SignalStrength signalStrength)

         switch (mTelephonyMgr.getPhoneType()){
         case TelephonyManager.PHONE_TYPE_CDMA:
            CurrentPhoneSignalStrength = String.valueOf(signalStrength.getCdmaDbm()) + c.getString(R.string.unit_dbm);;
         case TelephonyManager.PHONE_TYPE_GSM:
            int rssi = signalStrength.getGsmSignalStrength();
            int rssi_dbm = -113 + 2 *  rssi;
            CurrentPhoneSignalStrength = rssi_dbm + c.getString(R.string.unit_dbm) + " (" + rssi + c.getString(R.string.unit_asu) +")";
         case TelephonyManager.PHONE_TYPE_NONE:
            CurrentPhoneSignalStrength = NO_SIGNAL_STRENGTH;
         Log.d(TAG, "^ Signal strength changed: " + CurrentPhoneSignalStrength);
   };/* End of private Class */

What I would like is to find a way to delay the return of getCurrentSignalStrength() until a onSignalStrengthsChanged event has been fired at least once.

Due to the way I want to present the information (instant dump as text) I cannot change the gui when the event fires up.
Posts: 3
Joined: Mon Sep 06, 2010 6:29 pm


Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot], Majestic-12 [Bot], Yahoo [Bot] and 19 guests