public class Pedometer extends AndroidNonvisibleComponent implements Component, android.location.LocationListener, android.hardware.SensorEventListener, Deleteable
form
ACCELEROMETER_SENSITIVITY_MODERATE, ACCELEROMETER_SENSITIVITY_STRONG, ACCELEROMETER_SENSITIVITY_WEAK, ALIGNMENT_CENTER, ALIGNMENT_NORMAL, ALIGNMENT_OPPOSITE, ASSET_DIRECTORY, BUTTON_SHAPE_DEFAULT, BUTTON_SHAPE_OVAL, BUTTON_SHAPE_RECT, BUTTON_SHAPE_ROUNDED, COLOR_BLACK, COLOR_BLUE, COLOR_CYAN, COLOR_DEFAULT, COLOR_DKGRAY, COLOR_GRAY, COLOR_GREEN, COLOR_LTGRAY, COLOR_MAGENTA, COLOR_NONE, COLOR_ORANGE, COLOR_PINK, COLOR_RED, COLOR_WHITE, COLOR_YELLOW, DEFAULT_VALUE_COLOR_BLACK, DEFAULT_VALUE_COLOR_BLUE, DEFAULT_VALUE_COLOR_CYAN, DEFAULT_VALUE_COLOR_DEFAULT, DEFAULT_VALUE_COLOR_DKGRAY, DEFAULT_VALUE_COLOR_GRAY, DEFAULT_VALUE_COLOR_GREEN, DEFAULT_VALUE_COLOR_LTGRAY, DEFAULT_VALUE_COLOR_MAGENTA, DEFAULT_VALUE_COLOR_NONE, DEFAULT_VALUE_COLOR_ORANGE, DEFAULT_VALUE_COLOR_PINK, DEFAULT_VALUE_COLOR_RED, DEFAULT_VALUE_COLOR_WHITE, DEFAULT_VALUE_COLOR_YELLOW, DIRECTION_EAST, DIRECTION_MAX, DIRECTION_MIN, DIRECTION_NONE, DIRECTION_NORTH, DIRECTION_NORTHEAST, DIRECTION_NORTHWEST, DIRECTION_SOUTH, DIRECTION_SOUTHEAST, DIRECTION_SOUTHWEST, DIRECTION_WEST, FONT_DEFAULT_SIZE, LAYOUT_ORIENTATION_HORIZONTAL, LAYOUT_ORIENTATION_VERTICAL, LENGTH_FILL_PARENT, LENGTH_PREFERRED, LENGTH_UNKNOWN, SLIDER_MAX_VALUE, SLIDER_MIN_VALUE, SLIDER_THUMB_VALUE, TOAST_LENGTH_LONG, TOAST_LENGTH_SHORT, TYPEFACE_DEFAULT, TYPEFACE_MONOSPACE, TYPEFACE_SANSSERIF, TYPEFACE_SERIF
Constructor and Description |
---|
Pedometer(ComponentContainer container)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
CalibrateStrideLength()
Tells Whether stride length calibration is currently going on.
|
void |
CalibrateStrideLength(boolean cal)
Starts the process of calibrating the stride length by comparing number
of steps with the ditance covered (using the GPS).
|
void |
CalibrationFailed()
Indicates that the calibration has failed.
|
float |
Distance()
Returns the approximate distance traveled in meters.
|
long |
ElapsedTime()
Returns the time elapsed in milliseconds since the pedometer has started.
|
void |
GPSAvailable()
Indicates that the GPS is now available to use for distance measurement, and that
calibration is now possible.
|
void |
GPSLost()
Indicates that the GPS signal is lost.
|
boolean |
Moving()
Returns the current status of motion.
|
void |
onAccuracyChanged(android.hardware.Sensor sensor,
int accuracy) |
void |
onDelete() |
void |
onLocationChanged(android.location.Location loc) |
void |
onProviderDisabled(java.lang.String provider) |
void |
onProviderEnabled(java.lang.String provider) |
void |
onSensorChanged(android.hardware.SensorEvent event) |
void |
onStatusChanged(java.lang.String provider,
int status,
android.os.Bundle data) |
void |
Pause()
Pauses the counting of steps.
|
void |
Reset()
Resets the step count, distance, and clock.
|
void |
Resume()
Resumes the counting of steps.
|
void |
Save()
Saves the pedometer state to shared preferences.
|
void |
SimpleStep(int simpleSteps,
float distance)
Indicates that a step was taken.
|
void |
Start()
Starts the pedometer.
|
void |
StartedMoving()
Indicates that the device is moving.
|
void |
Stop()
Stops the pedometer.
|
int |
StopDetectionTimeout()
Returns the duration of idleness (no steps detected) after which to go into a "stopped" state.
|
void |
StopDetectionTimeout(int timeout)
Sets the duration of idleness (no steps detected) after which to go into a "stopped" state.
|
void |
StoppedMoving()
Indicates that the device has stopped.
|
float |
StrideLength()
Returns the current estimate of stride length in meters, if calibrated, or returns the
default (0.73 m) otherwise.
|
void |
StrideLength(float length)
Specifies the stride length in meters.
|
boolean |
UseGPS()
Returns whether the GPS is being used to measure distance.
|
void |
UseGPS(boolean gps)
Specifies whether to use GPS, if signal is available, to compute distance.
|
void |
WalkStep(int walkSteps,
float distance)
Indicates that a step was taken while walking.
|
getDispatchDelegate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDispatchDelegate
public Pedometer(ComponentContainer container)
public void Start()
public void Stop()
public void Reset()
public void Resume()
public void Pause()
public void Save()
public void SimpleStep(int simpleSteps, float distance)
simpleSteps
- number of raw steps detecteddistance
- approximate distance covered by number of simpleSteps in meterspublic void WalkStep(int walkSteps, float distance)
walkSteps
- number of walking steps detecteddistance
- approximate distance covered by the number of walkSteps in meterspublic void StartedMoving()
public void StoppedMoving()
public void CalibrationFailed()
public void GPSAvailable()
public void GPSLost()
public void CalibrateStrideLength(boolean cal)
public boolean CalibrateStrideLength()
true
if stride length calibration is currently going on,
false
otherwise.public void StrideLength(float length)
length
- is the stride length in meters.public float StrideLength()
public void StopDetectionTimeout(int timeout)
timeout
- the timeout in milliseconds.public int StopDetectionTimeout()
public void UseGPS(boolean gps)
true
by default.gps
- true
enables use of GPS,
false
disables GPSpublic boolean UseGPS()
true
if GPS is being used to measure distance, false
otherwise.public float Distance()
public boolean Moving()
true
if moving, false
otherwise.public long ElapsedTime()
public void onAccuracyChanged(android.hardware.Sensor sensor, int accuracy)
onAccuracyChanged
in interface android.hardware.SensorEventListener
public void onSensorChanged(android.hardware.SensorEvent event)
onSensorChanged
in interface android.hardware.SensorEventListener
public void onLocationChanged(android.location.Location loc)
onLocationChanged
in interface android.location.LocationListener
public void onProviderDisabled(java.lang.String provider)
onProviderDisabled
in interface android.location.LocationListener
public void onProviderEnabled(java.lang.String provider)
onProviderEnabled
in interface android.location.LocationListener
public void onStatusChanged(java.lang.String provider, int status, android.os.Bundle data)
onStatusChanged
in interface android.location.LocationListener
public void onDelete()
onDelete
in interface Deleteable