I want to create a watch app where i can input my weight. this will help track my weight easily.
- 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
• gradle dependencies
• healthconnect:
- android.permission.health.READ_WEIGHT
- android.permission.health.WRITE_WEIGHT • other required dependencies
• request the user to connect with health connect • explain why the app needs to connect to health connect
- 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
• 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).
• 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
- https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Mass
- https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/WeightRecord • https://developer.android.com/health-and-fitness/guides/health-connect/plan/data-types • https://developer.android.com/health-and-fitness/guides/health-connect/plan/onboard-users • https://developer.android.com/health-and-fitness/guides/health-connect/develop/read-data