Reputation: 73
I would like to get CellInfoGsm data, but I got some error.
CellInfoGsm is subclass of CellInfo. I don't know how to get the CellInfoGsm data.
Could someone help me to write the right code?
TelephonyManager TM = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
(CellInfoGsm) cellinfogsm = (CellInfoGsm)TM.getAllCellInfo();
Upvotes: 0
Views: 4342
Reputation: 36449
You have a couple of errors in your code.
(CellInfoGsm) cellinfogsm
needs to be changed to CellInfoGsm cellinfogsm
as you are not casting anything there.
getAllCellInfo();
returns a List. You must first choose one element in that list and work with it. Do this by writing CellInfoGsm cellinfogsm = (CellInfoGsm)TM.getAllCellInfo().get(0);
I used 0 as an example, you will first need to check the list's size then choose a CellInfo Object.
Upvotes: 2