Skip to content

Fixes for Wear tested on Pixel3 watch#1344

Merged
jonasoreland merged 2 commits into
masterfrom
wear-resume
May 3, 2026
Merged

Fixes for Wear tested on Pixel3 watch#1344
jonasoreland merged 2 commits into
masterfrom
wear-resume

Conversation

@jonasoreland
Copy link
Copy Markdown
Owner

@jonasoreland jonasoreland commented Apr 25, 2026

  1. make activity singletop, otherwise it sometimes starts 2 activites!
  2. add extra reading of data if it is missing
    it seems like there is some sort of life-cycle problem, honestly not 100% sure what, but this fixes the problem.

1) make activity singletop, otherwise it sometimes starts 2 activites!
2) add extra reading of data if it is missing
it seems like there is some sort of life-cycle problem,
honestly not 100% sure what, but this fixes the problem.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR targets Wear OS lifecycle/data-sync issues observed on a Pixel Watch 3 by preventing duplicate MainActivity instances and by re-reading Wear data items when local state appears incomplete.

Changes:

  • Set MainActivity to singleTop launch mode to reduce duplicate activity instances.
  • Add “read data if missing” behavior in MainActivity/StateService to repopulate phoneNode, headers, and trackerState when absent.
  • Improve logging/formatting around service connection, data change handling, and connection diagnostics.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
wear/src/main/java/org/runnerup/view/MainActivity.java Triggers readDataIfMissing() during resume and after service connection; minor formatting changes.
wear/src/main/java/org/runnerup/service/StateService.java Adds conditional data re-read logic and expands connection diagnostics/logging.
wear/src/main/AndroidManifest.xml Sets MainActivity launchMode to singleTop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +129 to +138
Context.BIND_AUTO_CREATE);
putDataItem(Constants.Wear.Path.WEAR_APP, true);
if (mStateService != null) {
mStateService.readDataIfMissing();
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

onResume() always calls bindService(...) even if the activity is already bound; if onResume() runs multiple times (common), this can create multiple binds that require matching unbindService(...) calls. Consider guarding the bind with if (!mIsBound) and/or unbinding in onPause()/onStop() to keep bind/unbind balanced.

Copilot uses AI. Check for mistakes.
Comment thread wear/src/main/AndroidManifest.xml Outdated
Comment thread wear/src/main/java/org/runnerup/service/StateService.java Outdated
Comment thread wear/src/main/java/org/runnerup/service/StateService.java Outdated
Copy link
Copy Markdown
Collaborator

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

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

Not run, not really understanding why the change is needed but the chenges look fine.
CoPilot suggestions seem reasonable to be, up to you.

Comment thread wear/src/main/java/org/runnerup/service/StateService.java Outdated
@jonasoreland
Copy link
Copy Markdown
Owner Author

Thanks, comments fixed. Will squash submit.

@gerhardol
Copy link
Copy Markdown
Collaborator

Thanks, comments fixed. Will squash submit.

Lint error, should probable be updated

Error: /home/runner/work/runnerup/runnerup/common/build.gradle:83: Error: A newer version of com.google.android.gms:play-services-wearable than 19.0.0 is available: 20.0.1 [GradleDependency]

@jonasoreland jonasoreland merged commit 2519bdf into master May 3, 2026
1 check failed
@jonasoreland
Copy link
Copy Markdown
Owner Author

Thanks, comments fixed. Will squash submit.

Lint error, should probable be updated

Error: /home/runner/work/runnerup/runnerup/common/build.gradle:83: Error: A newer version of com.google.android.gms:play-services-wearable than 19.0.0 is available: 20.0.1 [GradleDependency]

will fix in separate PR

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.

3 participants