I am having issues resolving this object it seems to be made completely out of a string then dynamically being matched to its key. if i try toString() this object it comes back with only the values(no keys) separated by a space. this is a SignalStrength java class. any help would be appreciated. The reason I am looking for the keys is the on particular phones the indexes seem to be different.
Asked
Active
Viewed 63 times
0

jambuls
- 111
- 11
-
1show the code that belongs to it – Tim Jul 19 '17 at 11:52
-
the object is recieved directly from this function https://developer.android.com/reference/android/telephony/PhoneStateListener.html#onSignalStrengthsChanged(android.telephony.SignalStrength) – jambuls Jul 19 '17 at 11:56
-
@jambuls add the info you provided in the question please, also explain a bit what you're trying to do and what's the problem. Right now the question is really hard to understand – vlatkozelka Jul 19 '17 at 11:57
-
can you not just use the getters for that class? – Tim Jul 19 '17 at 11:58
-
sadly it has only a few, but lots of values. so i am forced to Stringify to and split the object to have access to it via array indexes in order to get a particular value – jambuls Jul 19 '17 at 12:00
1 Answers
1
The SignalStrength class (source code) has about half its field getters annotated with @hide. This means they are not publicly accessible in the SDK with a get() like the other fields, hence android studio will not show those methods.
You have 2 options
Use
toString()
which provides values for all fields, and split it so you can access the values by index, like you are already doing.Get the field values by reflection. Example
Field field = null; try { field = SignalStrength.class.getDeclaredField("mLteRssnr"); if (field.getType().isAssignableFrom(int.class)) { field.setAccessible(true); int lteRssnr = (int) field.get(signalStrength); // pass the instance of SignalStrength here. } } catch (NoSuchFieldException e) { e.printStackTrace(); }

Tim
- 41,901
- 18
- 127
- 145