add snippets on how to request projected permissions from phone activity#969
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds PermissionsFromPhoneActivity.kt to demonstrate requesting glasses-specific hardware permissions from a host phone activity. The review feedback suggests adding the @RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM) annotation to the overridden onRequestPermissionsResult method to prevent Lint errors on lower API levels, and updating the permission result check to actually verify the deviceId parameter as described in the code comments.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| ) | ||
| // [END androidxr_projected_permissions_from_phone_activity_request_permission] | ||
| } | ||
| } catch (e: IllegalStateException) { |
There was a problem hiding this comment.
In particular: this is caused by @throws IllegalStateException if the projected device was not found, could we be specific here?
There was a problem hiding this comment.
Thanks for calling this out! Added!
| // Request the projected permission from phone activity | ||
| requestPermissions( | ||
| arrayOf(Manifest.permission.CAMERA), | ||
| REQUEST_CODE_GLASSES_CAMERA, |
There was a problem hiding this comment.
Please either add a comment about REQUEST_CODE_GLASSES_CAMERA or let the system manage the code; without context REQUEST_CODE_GLASSES_CAMERA looks like a constant that you might get from either Jetpack XR or some other library as opposed to a developer-defined constant.
There was a problem hiding this comment.
I added a comment about REQUEST_CODE_GLASSES_CAMERA being a dev defined constant as it's not possible to let the system manage the request code when requesting for projected hardware permission due to the deviceId being required.
Add snippets on how to request projected permissions from phone activity using the deviceId overload.