7 package com.google.appinventor.components.runtime;
14 import android.content.Context;
15 import android.hardware.Sensor;
16 import android.hardware.SensorEvent;
17 import android.hardware.SensorEventListener;
18 import android.hardware.SensorManager;
19 import android.os.Build;
21 import java.util.List;
30 private static final int DEFAULT_REFRESH_TIME = 1000;
31 private Sensor sensor;
39 super(container.
$form());
56 if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
59 sensorManager.registerListener(
this, sensor, timeInMicroseconds);
61 sensorManager.registerListener(
this, sensor, SensorManager.SENSOR_DELAY_UI);
75 @
SimpleProperty(description =
"Specifies whether or not the device has the "
76 +
"hardware to support the %type% component.")
88 @
SimpleProperty(description =
"If enabled, then device will listen for changes.")
102 defaultValue =
"True")
115 description =
"The requested minimum time in milliseconds between " +
116 "changes in readings being reported. Android is not guaranteed to honor the request. " +
117 "Setting this property has no effect on pre-Gingerbread devices.")
130 defaultValue = DEFAULT_REFRESH_TIME +
"")
143 final float[] values = sensorEvent.values;