Skip to content

Instantly share code, notes, and snippets.

@sonique6784
Last active October 10, 2025 10:14
Show Gist options
  • Select an option

  • Save sonique6784/82e03857190d402b2c6858585743a93a to your computer and use it in GitHub Desktop.

Select an option

Save sonique6784/82e03857190d402b2c6858585743a93a to your computer and use it in GitHub Desktop.
PROMPT: Watch app to add weight

Prompt: Watch app to add weight

I want to create a watch app where i can input my weight. this will help track my weight easily.

General Requirements

  • Weight can be in Kilogram or in pounds.
  • we need a health connect integration to read and write the weight, which is a "body measurement" using WeightRecord
  • The app will show a chart of weight evolution in the last 52 weeks

Detailed requirements

Setup the app with the right dependencies

• gradle dependencies

setup the app with the right permissions

• healthconnect:

  • android.permission.health.READ_WEIGHT
  • android.permission.health.WRITE_WEIGHT • other required dependencies

Setup Health Connect onboarding

• request the user to connect with health connect • explain why the app needs to connect to health connect

Last Weight record Screen

  • the last weight record needs to be pull from healthconnect • you need to create a screen to show the current weight and a button to add new weight

Add new Weight record

• you need a create a screen to edit the weight, the screen needs to be initialized with the current weight. if no current weight available, default to 70Kg (or equivalent in pounds) • when saved, the weight needs to be saved in healthconnect as WeightRecord, with time being "now", the Mass can be created using Mass.kilograms(value: Double) function or Mass.pounds(value: Double).

Chart Screen

• pull data from healthconnect for the last 52 week using HealthConnectClient, TimeRangeFilter and AggregateGroupByDurationRequest( metrics = setOf(WeightRecord.WEIGHT_AVG), timeRangeFilter = TimeRangeFilter.between(startTime, endTime), timeRangeSlicer = Duration.ofDays(7L) )

• Chart the data with a line chart

  • line needs to be bright green
  • background is black
  • grey horizontal line for X and Y axis
  • X time
  • Y weight

some usefull references to help you

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