My Kotlin code is
val t = cameraController.getCharacteristicInfo(myDataset[position])
if (t is Array<*>) {
holder.keyValue.text = Arrays.toString(t)
} else {
holder.keyValue.text = t.toString()
}
It is not working. if (t is Array<*>) always returns false.
The code of the function getCharacteristicInfo is:
public <T> T getCharacteristicInfo(CameraCharacteristics.Key<T> key) {
return characteristics.get(key);
}
It is a function for getting camera characteristics.
How to properly check if a variable is an array?
getCharacteristicInfo()?tis not actuallyArraytype. Could you edit your code to show type ofcharacteristicsandmyDataset[position]as well?myDataset[position]variable?getCharacteristicInforeturns value of typeTrelated toKey<T>being passed as parameter.myDataset[position]is some kind ofKey<T>(indeed, the code compiles) but may be is - e.g. -Key<String>and this forcestto be of typeString...