cordova-plugin-pedometer
cordova-plugin-pedometer copied to clipboard
cordova-plugin-pedometer not working on android: no sensors found
I tested the demo code on an android phone and got error: code 3, "No sensors found to register step counter listening to" any ideas? might this be an authorization issue? Thanks
my code:
alert("Start of Test1");
var successHandler = function (pedometerData) {
// pedometerData.startDate; -> ms since 1970
// pedometerData.endDate; -> ms since 1970
alert("step number:"+pedometerData.numberOfSteps);
// pedometerData.distance;
// pedometerData.floorsAscended;
// pedometerData.floorsDescended;
};
pedometer.startPedometerUpdates(successHandler, onError);
alert("End of Test1");
function onError(etext) {
alert("error="+JSON.stringify(etext));
}
========================================
my environment: Phone: Android 7.1.1, Moto E Cordova 8.0.0 cordova-plugin-pedometer 0.4.1 "Core Motion Pedometer"
I tested the demo code on an android phone and got error: code 3, "No sensors found to register step counter listening to" any ideas? might this be an authorization issue? Thanks
my code:
alert("Start of Test1"); var successHandler = function (pedometerData) { // pedometerData.startDate; -> ms since 1970 // pedometerData.endDate; -> ms since 1970 alert("step number:"+pedometerData.numberOfSteps); // pedometerData.distance; // pedometerData.floorsAscended; // pedometerData.floorsDescended; }; pedometer.startPedometerUpdates(successHandler, onError); alert("End of Test1"); function onError(etext) { alert("error="+JSON.stringify(etext)); }
========================================
my environment: Phone: Android 7.1.1, Moto E Cordova 8.0.0 cordova-plugin-pedometer 0.4.1 "Core Motion Pedometer"
As it turned out, the problem is not in the plugin. In some smartphones (in my case, Xiaomi Redmi Note 4), there is simply no hardware sensor with which this plugin works, namely Sensor.TYPE_STEP_COUNTER You can view its availability by an application like https://play.google.com/store/apps/details?id=com.cpuid.cpu_z In the absence of this sensor, the calculation of the number of steps is through interaction with the accelerometer, by analyzing and filtering data. According to this principle, applications from Google Play are working, which can count the number of steps on my device. What does the device have with a different type of sensor for counting the number of steps - Sensor.TYPE_SIGNIFICANT_MOTION After consulting with a programmer on JAVA, testing with examples, and making sure that it works, I ordered a plug-in revision with the inclusion of support for both types of sensor and accelerometer there.
Hi EvPut - is this something you would be willing to share? I would be happy to pay for it. You can reach me at email [email protected] (check my username) Thanks/Max
What does the device have with a different type of sensor for counting the number of steps - Sensor.TYPE_SIGNIFICANT_MOTION After consulting with a programmer on JAVA, testing with examples, and making sure that it works, I ordered a plug-in revision with the inclusion of support for both types of sensor and accelerometer there.
See issue#24 for an update since android 10.