Search code examples
javaandroidsignal-strength

How to extend the CellSignalStrength class when it doesn't have a constructor?


There is a class called CellSignalStrength that does not have a default constructor.

To be able to use SignalStrength, I have to make a class that extracts it, but I can't because when I try to do that, it prints out the error:

No default contstructor available for SignalStrength.

enter image description here

Also, there is another class called CellSignalStrengthGsm(same problem), but that class extends SignalStrength class, but how?


I've done some research on this, and i couldn't find anything, but this guide is only offering the signal strength of neighboring cell-sites to me, none of them is the one providing me with the signal. That solution is offering no actual signal strength.

Why doesn't the Android documentation have at least one example for how to use the class?

I really need help on this, I'm stuck :/


Solution

  • The only reason I can think of why you can't extend the CellSignalStrength class is because its constructor is protected CellSignalStrength(). Meaning only other classes in the same package may extend it.

    The Android developers probably had good reason to do so. My suggestion would be to rethink what you're trying to do and figure out another solution. Perhaps using an instance of one of the classes that sub-classes CellSignalStrength:

    Note: These classes are all final, so don't try to extend them.
    
    CellSignalStrengthCdma
    CellSignalStrengthGsm
    CellSignalStrengthLte
    CellSignalStrengthWcdma