My Android app targets SDK 28 and connects to Google Fit to upload data and read some other data. The app uses the HistoryAPI to read com.google.step_count.delta data.
T
Not sure if it helps for your issue but it helps us with similar problem. First check if your app/user has Physical activity permitted - most probably not. If you permit it - your code should run without exception.
Issue for us was how to detect that com.google.android.gms.permission.ACTIVITY_RECOGNITION is permitted (running in target sdk 28 on Android 10) - since call
PermissionCompat.isPermissionGranted(context,"com.google.android.gms.permission.ACTIVITY_RECOGNITION")
always returns true (even permission is denied)
workaround (for your app target sdk 28 runnning on Android 10) is to call requestPermission (instead of isPermissionGranted) which does not do anything when permission is granted and show dialog if not
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
PermissionCompat.requestPermission(activity, "com.google.android.gms.permission.ACTIVITY_RECOGNITION", requestCode)
}
in case you are running background code where activity is not available you have two options: