심박수 체크 앱을 만들어보자
참고 프로젝트 : https://github.com/android/health-samples, https://github.com/android/wear-os-samples
rememberSwipeDismissableNavController
를 사용해서 화면을 넘길 수 있다.rememberLauncherForActivityResult
와 rememberPermissionState
를 사용하여 권한을 체크하자!WatchScaffold
: Swipe로 화면 나가기 가능AppScaffold
: Swipe 불가능AmbientAware(isAlwaysOnScreen = isAlwaysOnScreen) **{** ambientStateUpdate **->
** 으로 절전모드(?)를 체크해 UI를 변경 해 줄 수있다만약 AmbientStateUpdate의 AmbientState가 Ambitent라면 심박수가 들어오지않는다.
이럴땐 batchingModeOverrides를 추가해주면 5초마다 심박수가 들어온다.
val config = ExerciseConfig(
exerciseType = ExerciseType.BIKING,
dataTypes = dataTypes,
isAutoPauseAndResumeEnabled = supportsAutoPauseAndResume,
isGpsEnabled = false,
exerciseGoals = exerciseGoals,
**batchingModeOverrides = setOf(BatchingMode.HEART_RATE_5_SECONDS)**
)
ExerciseType
으로 원하는 운동을 지정해 줄 수 있다. (biking, bench press 등등)
ExerciseUpdateCallback
을 받아 데이터를 처리한다. (onExerciseUpdateReceived
로 최신 데이터가 들어온다)