Note that there are some explanatory texts on larger screens.

plurals
  1. POMy PhoneStateListener is not being called for showing signal strength
    primarykey
    data
    text
    <p>I am trying to show the current signal strength and current cell ID and Lac in my application for 3g network. Since it has to be compatible for API-8, I am using SignalStrength class from android.telephony. When I click a button, for now I want it to show the CID, Lac and signal strength of current cell. I am getting the CID and lac but the signal strength is always showing 0. The code is given below:</p> <pre><code>public void onClick(View v) { switch (v.getId()) { case R.id.bShowCell: GsmCellLocation location; String cellID = ""; String lac = ""; Context context = (Context) getApplicationContext(); TelephonyManager tm = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); location = (GsmCellLocation) tm.getCellLocation(); cellID = String.valueOf(location.getCid()); lac = String.valueOf(location.getLac()); CurCell.setText(cellID); CellLac.setText(lac); CurStrgth.setText(getRSSI()); } } public String getRSSI() { MyListener = new MyPhoneStateListener(); Tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); Tel.listen(MyListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); String strength = MyListener.getStrength(); return strength; } class MyPhoneStateListener extends PhoneStateListener { public int singalStrengths; @Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { super.onSignalStrengthsChanged(signalStrength); int asu = signalStrength.getGsmSignalStrength(); singalStrengths = -113 + 2 * asu; } public String getStrength() { return String.valueOf(singalStrengths); } } </code></pre> <p>I have checked many examples online and I think my code is okay. But when I checked it in debug mode, I see that when I click the button, the program never goes in onSignalStrengthsChanged. Is there anything I am missing? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload