Skip to content

Adding code snippets for wake locks doc #582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 12, 2025
Merged

Adding code snippets for wake locks doc #582

merged 4 commits into from
Aug 12, 2025

Conversation

asolovay
Copy link
Contributor

@asolovay asolovay commented Aug 7, 2025

Starting with the code snippets to add and release a wake lock, we can add other snippets later.

Used by docs in:

https://developer.android.com/develop/background-work/background-tasks/awake/wakelock/

The actual snippets used on the DAC pages are bracketed by the [START ...] and [END ...] comments; everything else is just scaffolding to get the snippet to compile.

Starting with the code snippets to add and release a wake lock, we can add other snippets later.

Used by docs in:

https://developer.android.com/develop/background-work/background-tasks/awake/wakelock/
@asolovay asolovay self-assigned this Aug 7, 2025
@asolovay asolovay marked this pull request as ready for review August 7, 2025 21:39
Copy link

snippet-bot bot commented Aug 7, 2025

Here is the summary of changes.

You are about to add 4 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

@asolovay asolovay requested a review from AliceYuan August 7, 2025 21:39
asolovay and others added 2 commits August 8, 2025 16:19
One of the region tags was misnamed (had the _kotlin suffix
instead of _java).
Copy link

@AliceYuan AliceYuan left a comment

Choose a reason for hiding this comment

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

lgtm!

}

// [START android_backgroundwork_wakelock_release_java]
void doSomethingAndRelease() throws MyException {

Choose a reason for hiding this comment

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

what if it just throws Exception instead? I'm not sure if we need the custom exception here

@asolovay asolovay merged commit 79a26f9 into main Aug 12, 2025
5 checks passed
@asolovay asolovay deleted the wakelock_snippets branch August 13, 2025 18:13
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