samsung-health-data-sdk
2
总安装量
2
周安装量
#64434
全站排名
安装命令
npx skills add https://github.com/itsramiel/skills --skill samsung-health-data-sdk
Agent 安装分布
amp
2
gemini-cli
2
claude-code
2
github-copilot
2
codex
2
kimi-cli
2
Skill 文档
Samsung Health Data SDK v1.0.0
Kotlin-first SDK for reading, writing, and aggregating health data from the Samsung Health app on Android. Replaces the deprecated Samsung Health SDK for Android (EOL July 31, 2025).
Key traits:
- All data operations are
suspendfunctions (Kotlin coroutines) with*Async()callback alternatives - Permission-first access â must request and receive user consent before any data operation
- Package root:
com.samsung.android.sdk.health.data
When to Apply
Use this skill when the user mentions:
- Samsung Health, Samsung Health Data SDK, health data on Samsung/Android
- Specific data types: heart rate, blood glucose, blood oxygen, blood pressure, steps, exercise, sleep, nutrition, body composition, body temperature, skin temperature, floors climbed, water intake, energy score, activity summary
- SDK classes:
HealthDataStore,HealthDataService,DataTypes.*,HealthDataPoint,DeviceManager - Operations: reading/writing health data, aggregating steps/heart rate, tracking health data changes, managing health permissions on Samsung
Quick Start
import com.samsung.android.sdk.health.data.*
import com.samsung.android.sdk.health.data.data.*
import com.samsung.android.sdk.health.data.permission.*
import com.samsung.android.sdk.health.data.request.*
import com.samsung.android.sdk.health.data.error.*
// 1. Get the store
val healthDataStore = HealthDataService.getStore(context)
// 2. Request permissions
val permissions = setOf(
Permission.of(DataTypes.HEART_RATE, AccessType.READ),
Permission.of(DataTypes.BLOOD_GLUCOSE, AccessType.READ),
Permission.of(DataTypes.BLOOD_GLUCOSE, AccessType.WRITE)
)
try {
val granted = healthDataStore.getGrantedPermissions(permissions)
if (!granted.containsAll(permissions)) {
healthDataStore.requestPermissions(permissions, activity)
}
} catch (e: ResolvablePlatformException) {
if (e.hasResolution) e.resolve(activity)
}
// 3. Read data
val request = DataTypes.HEART_RATE.readDataRequestBuilder
.setLocalTimeFilter(LocalTimeFilter.of(startTime, endTime))
.setOrdering(Ordering.DESC)
.build()
val heartRateList = healthDataStore.readData(request).dataList
Quick Reference â All Data Types
| DataType Constant | Type Class | R | W | Agg | Change | Reference |
|---|---|---|---|---|---|---|
DataTypes.HEART_RATE |
HeartRateType | Y | Y | MIN, MAX | Y | vitals-types |
DataTypes.BLOOD_GLUCOSE |
BloodGlucoseType | Y | Y | â | Y | vitals-types |
DataTypes.BLOOD_OXYGEN |
BloodOxygenType | Y | Y | â | Y | vitals-types |
DataTypes.BLOOD_PRESSURE |
BloodPressureType | Y | Y | â | Y | vitals-types |
DataTypes.BODY_TEMPERATURE |
BodyTemperatureType | Y | Y | â | Y | vitals-types |
DataTypes.SKIN_TEMPERATURE |
SkinTemperatureType | Y | â | â | Y | vitals-types |
DataTypes.ENERGY_SCORE |
EnergyScoreType | Y | â | â | Y | vitals-types |
DataTypes.FLOORS_CLIMBED |
FloorsClimbedType | Y | Y | TOTAL | Y | vitals-types |
DataTypes.EXERCISE |
ExerciseType | Y | Y | TOTAL_CALORIES, TOTAL_DURATION | Y | exercise-and-sleep-types |
DataTypes.SLEEP |
SleepType | Y | Y | TOTAL_DURATION | Y | exercise-and-sleep-types |
DataTypes.STEPS |
StepsType | â | â | TOTAL | â | aggregation-and-changes |
DataTypes.NUTRITION |
NutritionType | Y | Y | TOTAL_CALORIES | Y | nutrition-body-activity-types |
DataTypes.BODY_COMPOSITION |
BodyCompositionType | Y | Y | â | Y | nutrition-body-activity-types |
DataTypes.WATER_INTAKE |
WaterIntakeType | Y | Y | TOTAL | Y | nutrition-body-activity-types |
DataTypes.ACTIVITY_SUMMARY |
ActivitySummaryType | â | â | TOTAL_* | â | nutrition-body-activity-types |
DataTypes.STEPS_GOAL |
StepsGoalType | â | â | LAST | â | nutrition-body-activity-types |
DataTypes.ACTIVE_CALORIES_BURNED_GOAL |
ActiveCaloriesBurnedGoalType | â | â | LAST | â | nutrition-body-activity-types |
DataTypes.ACTIVE_TIME_GOAL |
ActiveTimeGoalType | â | â | LAST | â | nutrition-body-activity-types |
DataTypes.NUTRITION_GOAL |
NutritionGoalType | â | â | LAST_CALORIES | â | nutrition-body-activity-types |
DataTypes.WATER_INTAKE_GOAL |
WaterIntakeGoalType | â | â | LAST | â | nutrition-body-activity-types |
DataTypes.SLEEP_GOAL |
SleepGoalType | â | â | LAST_BED_TIME, LAST_WAKE_UP_TIME | â | nutrition-body-activity-types |
DataTypes.USER_PROFILE |
UserProfileDataType | Y | â | â | â | nutrition-body-activity-types |
Quick Reference â Operations
| Operation | Method | Builder Access | Reference |
|---|---|---|---|
| Read | healthDataStore.readData(request) |
DataTypes.X.readDataRequestBuilder |
crud-operations |
| Insert | healthDataStore.insertData(request) |
DataTypes.X.insertDataRequestBuilder |
crud-operations |
| Update | healthDataStore.updateData(request) |
DataTypes.X.updateDataRequestBuilder |
crud-operations |
| Delete | healthDataStore.deleteData(request) |
DataTypes.X.deleteDataRequestBuilder |
crud-operations |
| Aggregate | healthDataStore.aggregateData(request) |
DataType.XType.OPERATION.requestBuilder |
aggregation-and-changes |
| Read Changes | healthDataStore.readChanges(request) |
DataTypes.X.changedDataRequestBuilder |
aggregation-and-changes |
| Read Associated | healthDataStore.readAssociatedData(request) |
DataTypes.X.associatedReadRequestBuilder |
crud-operations |
| Helper read | healthDataStore.read(DataTypes.X) { ... } |
Extension function | crud-operations |
Quick Reference â Filters
| Filter | Factory | Used In |
|---|---|---|
LocalTimeFilter |
LocalTimeFilter.of(start: LocalDateTime, end: LocalDateTime) |
Read, Delete |
LocalDateFilter |
LocalDateFilter.of(start: LocalDate, end: LocalDate) |
Aggregate |
InstantTimeFilter |
InstantTimeFilter.of(start: Instant, end: Instant) |
Changes, some Read/Delete |
ReadSourceFilter |
.fromDeviceType(), .fromLocalDevice(), .fromApplicationId(), .fromPlatform() |
Read |
AggregateSourceFilter |
.fromPlatform() |
Aggregate |
IdFilter |
.fromDataUid(uid), .fromClientDataId(id) |
Read, Update, Delete |
See filters-and-groups for full details.
Problem â Reference Mapping
| Question | Go To |
|---|---|
| How do I set up the SDK / Gradle / dependencies? | setup-and-initialization |
| How do I request permissions? | setup-and-initialization |
| How do I read / insert / update / delete data? | crud-operations |
| How do I aggregate steps, heart rate, calories? | aggregation-and-changes |
| How do I track data changes (delta sync)? | aggregation-and-changes |
| What fields does exercise / sleep have? | exercise-and-sleep-types |
| What fields do heart rate / blood glucose / BP have? | vitals-types |
| What fields do nutrition / body composition have? | nutrition-body-activity-types |
| How do filters and time grouping work? | filters-and-groups |
| How do I handle errors and exceptions? | error-handling |
| How do I register / query devices? | device-management |