androidcellinfo5g

Is there a way to make a CellInfoNr to CellSignalStrengthNr?


I'm looking for a documentation for output a inner cellinfo like RSRP, RSRQ, SINR, RSSI.

And I want to look upon 5G(New Radio) data.

cellRSRP = ((CellSignalStrengthNr) ((CellInfoNr) cellInfo).getCellSignalStrength()).getCsiRsrp();

This is what I've tried to get a cellRSRP of 5G. It quite a lot similar to get LTE data.


And this doesn't work, because I deliberately cast

(CellSignalStrengthNr)

on this code

((CellInfoNr) cellInfo).getCellSignalStrength())

Since the getCellSignalStrength() doesn't return CellSignalStrengthNr data, (It returns CellSignalStrength)

so I just cast on the code, no error detected, everything was seemed to going fine.

But It was not and I came here to ask a question.

So, in a nutshell,

  1. Is there a normal way to make CellSignalStrengthNr without casting?
  2. Or should I try more different ways with casting?

Solution

  • according to code in android.telephony, CellSignalStrengthNr extends CellSignalStrength.

    So, I don't think you need to make CellSignalStrength to CellSignalStrengthNr. If "telephonyManager.requestCellInfoUpdate()" returns CellInfoNr, CellSignalStrength in CellInfoNr is CellSignalStrengthNr.

    just do..

    CellInfoNr cellinfo = ((CellInfoNr) cellInfo)
    CellSignalStrengthNr signal = ((CellSignalStrengthNr) cellinfo.getCellSignalStrength())