Skip to content Skip to sidebar Skip to footer

Step Counter In Android (counter Sensor Doesn't Work)

I try to make a basic pedometer app in android. But when I am getting below error Counter sensor not available Please help me. package com.starboardland.pedometer; import andro

Solution 1:

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.

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

Post a Comment for "Step Counter In Android (counter Sensor Doesn't Work)"