Skip to content

add snippets on how to request projected permissions from phone activity#969

Open
trambui09 wants to merge 4 commits into
android:mainfrom
trambui09:tb/june-request-projected-permissions-from-phone-activity
Open

add snippets on how to request projected permissions from phone activity#969
trambui09 wants to merge 4 commits into
android:mainfrom
trambui09:tb/june-request-projected-permissions-from-phone-activity

Conversation

@trambui09

Copy link
Copy Markdown
Contributor

Add snippets on how to request projected permissions from phone activity using the deviceId overload.

@trambui09 trambui09 marked this pull request as ready for review June 25, 2026 00:32
@trambui09 trambui09 requested a review from a team as a code owner June 25, 2026 00:32

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread xr/src/main/java/com/example/xr/projected/PermissionsFromPhoneActivity.kt Outdated
)
// [END androidxr_projected_permissions_from_phone_activity_request_permission]
}
} catch (e: IllegalStateException) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular: this is caused by @throws IllegalStateException if the projected device was not found, could we be specific here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for calling this out! Added!

// Request the projected permission from phone activity
requestPermissions(
arrayOf(Manifest.permission.CAMERA),
REQUEST_CODE_GLASSES_CAMERA,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@snippet-bot

snippet-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 10 region tags.
You are about to delete 7 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants