How to get field name in android

Viewed 173

I'm creating camera app and I want to log infos about camera state. Now I'm using:

Log.i("AF state", String.valueOf(result.get(CaptureResult.CONTROL_AF_STATE)));

It returns values like:

I/AF state: 1

It is hard to read and I'm curious if there is a way to log field names that these numbers represent, for example:

I/AF state: CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED
1 Answers

You can use getName()

Log.i("AF state", result.get(CaptureResult.CONTROL_AF_STATE).getName());

from Android Developer Docs

Return a camelCase, period separated name formatted like:

"root.section[.subsections].name".
Related