3
votes

I tried to count steps in real time using Google Fit SDK.

I used Sensor API to get step count changes in real time and it worked fine if I have Google Fit app installed on my phone.

But when I uninstalled Google Fit app, it didn't worked.

Can anyone tell me what I did wrong and what should I do?

Thanks

1
It's not working... It logs "Count sensor not available!" - ppianist

1 Answers

1
votes

I found this answer, hope it helps you

The Android 4.4 API Documentation states that the sensors are hardware dependent.

Both step sensors are hardware dependent (Nexus 5 is the first device to support them), so you should check for availability with hasSystemFeature(), using the FEATURE_SENSOR_STEP_DETECTOR and FEATURE_SENSOR_STEP_COUNTER constants.

You should check if the device has the functionality first.

PackageManager pm = getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_STEP_COUNTER)) {
    // the awesome stuff here
}