Skip to content

Change to avoid recreating notification and ongoing activity#10

Open
garanj wants to merge 1 commit intomainfrom
oa-update
Open

Change to avoid recreating notification and ongoing activity#10
garanj wants to merge 1 commit intomainfrom
oa-update

Conversation

@garanj
Copy link
Copy Markdown
Contributor

@garanj garanj commented Apr 28, 2026

Update codelab to avoid recreating notification and ongoing activity for each status update

Instead, maintain a reference to the ongoing activity and just update using ongoingActivity.update(...).

Codelab documentation to be updated once these changes land.

Copy link
Copy Markdown

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

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 integrates the Ongoing Activity API into the ForegroundOnlyWalkingWorkoutService for both the start and finished modules. Key changes include refactoring notification updates into a centralized updateOngoingActivity method and adding required permission annotations. Feedback focuses on a functional regression in the start module where the new update method is left as a TODO, effectively disabling notification updates that previously worked. There is also a request to restore an accidentally deleted log statement to maintain consistency between the project modules.

Comment on lines +223 to +224
val updatedStatus = getString(R.string.walking_points_text, walkingPoints)
updateOngoingActivity(updatedStatus)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

This change replaces the notification update logic with a call to updateOngoingActivity, which is currently an empty method with a TODO. This results in a functional regression where the walking points are no longer updated in the notification for the start version of the codelab. While this might be to set up an exercise for the user, it leaves the app in a non-working state. Consider preserving the old notification update logic within the new updateOngoingActivity method to ensure the app remains functional at the beginning of this codelab step.

// NOTE: If this method is called due to a configuration change in MainActivity,
// we do nothing.
if (!configurationChange && walkingWorkoutActive) {
Log.d(TAG, "Start foreground service")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This log statement, which is useful for debugging, was removed. However, it's kept in the finished version of the file. This seems like an accidental deletion and introduces an inconsistency between the start and finished states of the codelab. Please consider keeping it.

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