Note that there are some explanatory texts on larger screens.

plurals
  1. POSome GSM devices crashing with CDMA SignalStrength error on Android
    primarykey
    data
    text
    <p>My Android app monitors cellular signal strengths. On CDMA devices, it works without any problems. On <em>many</em> GSM devices, it works without any problems. However, on <em>some</em> GSM devices, I am getting force closes with the following error message:</p> <p><strong>java.lang.ClassCastException: android.telephony.cdma.CdmaCellLocation cannot be cast to android.telephony.gsm.GsmCellLocation</strong></p> <p>I am fairly certain that this issue occurs on some Samsung devices in the US when they receive a 4G LTE signal; I believe it occurs on other devices and countries as well. I am still trying to determine the exact service providers and devices involved.</p> <p>Here is the relevant snippet of code from MyService.java; I have marked the line referenced by the error message with <code>//********</code>:</p> <pre><code>public void onCreate() { tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); ... } public int onStartCommand(Intent in, int flags, int startId) { signalStrengthListener = new SignalStrengthListener(); ((TelephonyManager)getSystemService(TELEPHONY_SERVICE)).listen(signalStrengthListener, SignalStrengthListener.LISTEN_SIGNAL_STRENGTHS | SignalStrengthListener.LISTEN_SERVICE_STATE | SignalStrengthListener.LISTEN_DATA_CONNECTION_STATE | SignalStrengthListener.LISTEN_CELL_LOCATION); return START_STICKY; ... } public void onSignalStrengthsChanged(SignalStrength signalStrength) { isGSM = signalStrength.isGsm(); if (isGSM == true) { GCellLoc = (GsmCellLocation)tm.getCellLocation(); //******** ... } </code></pre> <p>Not sure why is anything from <code>android.telephony.cdma</code> is appearing if this code should only be triggered when <code>isGSM</code> returns true. Perhaps when an LTE signal is detected, that puts the phone in some sort of dual CDMA/GSM mode as far as the Android API is concerned? I have not been able to find any documentation of similar behavior. How can I handle this in my code? Thanks.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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