What exactly is CellInfo and how to use getAllCellInfo to get info just about one connectivity type?

1.8k views Asked by At

GOAL: get info (signal strength) of a particular type of connectivity (the one I'm actually using).

PROBLEM: I'm not sure to understand exactly what does reperesent CellInfo and how to extract info from getAllCellInfo

QUESTIONS:

1) From android developer website

CellInfo: Immutable cell information from a point in time.

What does it mean?

2) I want to understand if I'm using wcdma, umts, gsm or lte. I've found here a snippet of code using getAllCellInfo , below my adapted version to get the signal strength

  for (final CellInfo info : telephonyManager.getAllCellInfo()) {

            if (info instanceof CellInfoGsm) {

                final CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength();
                if(gsm.getLevel() >= localMaxSignalStrength)
                     localMaxSignalStrength = gsm.getLevel();
                Toast.makeText(getApplicationContext(), "gsm rssi" + localMaxSignalStrength, Toast.LENGTH_LONG).show();

            } else if (info instanceof CellInfoWcdma) {

                final CellSignalStrengthWcdma cdma = ((CellInfoWcdma) info).getCellSignalStrength();
                if(cdma.getLevel() >= localMaxSignalStrength)
                    localMaxSignalStrength = cdma.getLevel();
                Toast.makeText(getApplicationContext(), "wcdma rssi" + localMaxSignalStrength, Toast.LENGTH_LONG).show();

            } else if (info instanceof CellInfoLte) {

                final CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength();
                if(lte.getLevel() >= localMaxSignalStrength)
                    localMaxSignalStrength = lte.getLevel();
                Toast.makeText(getApplicationContext(), "lte rssi" + localMaxSignalStrength, Toast.LENGTH_LONG).show();

Now from what I've read on Android developer website

getAllCellInfo() : Returns all observed cell information from all radios on the device including the primary and neighboring cells. Calling this method does not trigger a call to onCellInfoChanged(), or change the rate at which onCellInfoChanged() is called.

The list can include one or more CellInfoGsm, CellInfoCdma, CellInfoLte, and CellInfoWcdma objects, in any combination.

so it means that getAllCellInfo() doesn't return just one kind of connectivity info, but they can be mixed. I want to understand if my phone is using all of the returned ones or just one of them (and in the latter case how to find which one I'm using).

0

There are 0 answers