-
Dec 26th, 2016, 05:02 AM
#1
Thread Starter
Banned
How to count Steps in Android Programming?
I am a developer. I have been searching for mobile development forum which can help me in learning the latest Android development features including Apps development. I want to figure out how we can count and detect steps in Android programming including sensors. I have searched alot of forums for my issue. I hope any tech developer can help me in resolving the issue.
-
Feb 13th, 2017, 08:26 PM
#2
Re: How to count Steps in Android Programming?
out of curiousity, did you post something about this in an ivy tech forum last semester?
-
Mar 15th, 2017, 12:19 AM
#3
Banned
Re: How to count Steps in Android Programming?
Step Counter: This keeps a count of the number of steps that you have taken. The counter is only reset when you re-boot the device, else, for every step you take (or the phone thinks you took, you counts up).
Step Detector: This sensor just detects when you take a step. That’s it.
// Step Counter
sManager.registerListener(new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
float steps = event.values[0];
textViewStepCounter.setText((int) steps + “”);
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
}, sManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER),
SensorManager.SENSOR_DELAY_UI);
// Step Detector
sManager.registerListener(new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
// Time is in nanoseconds, convert to millis
timestamp = event.timestamp / 1000000;
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
}, sManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR),
SensorManager.SENSOR_DELAY_UI);
-
Mar 16th, 2017, 08:26 AM
#4
Member
Re: How to count Steps in Android Programming?
Working with sensors in B4A: https://www.b4x.com/android/forum/th....6647/#content
You need to pass 19 (TYPE_STEP_COUNTER) for the SensorType parameter. Note that it is only supported by Android 4.4+.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|