android-sensors

Android - Event after detecting 'x' number of rolls around local Z axis

帅比萌擦擦* 提交于 2019-12-12 03:22:43
问题 I'm currently struggling with the use of detectors in Android. I'm working on an app, and I'd like it to perform certain operations after the user make their phone 'roll' in their hand. To be more precise, I'd like them to roll their phone 720° around the local Z Axis (if I'm not mistaken, the 'height' of the phone) and then, have the app return something. I really don't know how to do this. So far, the best I've came up with was to declare 8 boolean variables accounting each for a quarter of

Can't register more than one Sensor in Android Service

前提是你 提交于 2019-12-12 02:36:08
问题 I have a service which is called from an Activity. This Service Registers all Sensors and Registers Listener against them. EDIT: I have removed the two lines in onSensorChange() **sensorManager.unregisterListener(this); sensorManager = null;** AND now it works. WHY? The Problem is that when I do them one at a time, my application works fine but if I register more than one sensor, My application crashes. Here is the OnCreate Function of my Service: @Override public void onCreate() { super

Android detect turn from phone

偶尔善良 提交于 2019-12-12 02:27:04
问题 I want to detect, if my smartphone user turn left or right or doing a turn around. Here an example to explain "turn right": The User faces a crossroad. Now I want to detect if my user takes the right path or the left path or goes straight on. therefore i use this to get azimuth: @Override public void onSensorChanged(SensorEvent event) { switch (event.sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: for (int i = 0; i < 3; i++) { valuesAccelerometer[i] = event.values[i]; } break; case Sensor

Get the direction Android app user is headed on entering a geofence

给你一囗甜甜゛ 提交于 2019-12-12 01:22:04
问题 I'm playing around with geofences - what I'd like to do is when a geofence is fired, figure out which direction they're going. For example - let's ay I want to setup a geofence around a Culvers. While driving down the interstate heading north, when I enter the geofence I want to pop-up a notification that says "Culvers, take next exit on the right and make a right heading East". But if they're driving South on the interstate, it should pop-up and say "Culvers, take next exit on the right and

Android: Shakelistener error

天涯浪子 提交于 2019-12-12 00:33:41
问题 i have a shake listener as follows public class ShakeListener implements SensorEventListener { private String TAG = ShakeListener.class.getSimpleName(); private static final int FORCE_THRESHOLD = 800; private static final int TIME_THRESHOLD = 100; private static final int SHAKE_TIMEOUT = 500; private static final int SHAKE_DURATION = 1000; private static final int SHAKE_COUNT = 5; private SensorManager mSensorMgr; private float mLastX = -1.0f, mLastY = -1.0f, mLastZ = -1.0f; private long

How to set delay of Android Sensors programmatically?

北战南征 提交于 2019-12-11 23:15:21
问题 If there any method to change delay of andriod sensor other using constant like "Normal_Delay, ...". I want to put the delay value as I like. if this is possible ? Actually, I found a solution by using "handler" but it doesn't work. Here is the solution with Handler but it doesn't work: public void registerSensorListener() { String sensorName = PackageManager.FEATURE_SENSOR_ACCELEROMETER; if (mHandlerThread == null) { mHandlerThread = new HandlerThread("sensorThread"); } if (!mHandlerThread

Obtaining sensors data while the screen is off (Android 4.0+)

送分小仙女□ 提交于 2019-12-11 18:46:03
问题 As far as I know on Android devices there is no 100%-sure way to get the data from device sensors while the screen is off. There are some workarounds, but they do not work always. But all the posts I read were describing Android versions ~2.2. Does anyone know whether the bug was fixed in Android 4.0+ ? 回答1: This WakeLock works like charm. 来源: https://stackoverflow.com/questions/11612065/obtaining-sensors-data-while-the-screen-is-off-android-4-0

Sensor List in Samsung GT-I9300

只愿长相守 提交于 2019-12-11 18:40:08
问题 Please help.I am trying to get all the available sensors of a android device.But when i tried to get from 'GT_19300' it shows a list given below "LSM330DLC 3-axis Accelerometer AK8975C 3-axis Magnetic field sensor iNemoEngine Orientation sensor CM36651 Light sensor CM36651 Proximity sensor LSM330DLC Gyroscope sensor iNemoEngine Gravity sensor iNemoEngine Linear Acceleration sensor iNemoEngine Rotation_Vector sensor LPS331AP Pressure Sensor Rotation Vector Sensor Gravity Sensor Linear

Calibration of gravity and magnetic field sensor in Android

烂漫一生 提交于 2019-12-11 15:37:32
问题 I have a Huawei P9 Plus smartphone running Android 7.0 and I have written an App which collects sensor data. For the gravity sensor Android is telling me that the accuracy is unreliable. For the magnetic field sensor I'm getting medium accuracy. For all other sensor I have high accuracy. Is there a way to calibrate the gravity and magnetic field sensor? 来源: https://stackoverflow.com/questions/54770132/calibration-of-gravity-and-magnetic-field-sensor-in-android

Measuring vertical movement of non-fixed Android device

会有一股神秘感。 提交于 2019-12-11 13:57:10
问题 My goal is to make an Android mobile app (SDK16+) that measures road quality while riding a bike. I have found a Sensor fusion demo for Android that I assume will do all the measurements for me. How can I get only the vertical movement when the phone is not fixed in a certain orientation? 回答1: The problem The problem here is that you have two systems of coordinates, the dx, dy, dz, of your device and the wX, wY, wZ of the world around you. The relationship between the two changes as you move