sensormanager

SensorEventListener not unregistering itself

[亡魂溺海] 提交于 2019-12-11 16:35:52
问题 I have been developing an application which needs to perform accelerometer calibration in several steps. What I have done, is create a SensorEventListener that gets a certain amount of readings, and after that amount is reached, I call 'sensorManager().unregisterListener(eventListener)'. However, I think this line is not unregistering the listener, since immediately afterwards, the same line is called, as a result of continuing to run. Question: am I doing things properly this way, or should

SensorManager.getRotationMatrix strange behavior

北慕城南 提交于 2019-12-11 08:16:41
问题 I am implementing a compass, getting readings from SensorManager.getRotationMatrix (see code below). I have an imageView that rotates using RotateAnimation . The compass and animation works fine except for one issue: Through the SensorManager.getOrientation I get an array of three values - Azimuth, Pitch and Roll. I only use the array[0] which holds the Azimuth Value If I hold the phone flat and turn it around on the Z axis (azimuth) - it works perfectly. But, the minute I tilt the phone on

Inconsistent orientation sensor values on Android for azimuth/yaw and roll

烂漫一生 提交于 2019-12-09 06:24:23
问题 I’m having trouble getting good orientation sensor readings. The sensor readings seemed unreliable, so I tested my code against two free sensor test apps (Sensor Tester (Dicotomica) and Sensor Monitoring (R's Software)). I found that while my readings often agreed with the sensor test apps, occasionally the values for azimuth/yaw, and roll differed by up to 40 degrees, although the pitch reading mostly agreed. The two free apps always seemed to agree with each other. I put my code into a tiny

Android sensor sampling rate won't drow below 60 hz

痞子三分冷 提交于 2019-12-08 10:14:09
问题 I'm reading out the accelerometer sensor on a Sony Smartwatch 3. Since the Android Wear 1.5 update the sampling rate won't drop below about 60hz, regardless weather I use SENSOR_DELAY_NORMAL , SENSOR_DELAY_UI or SENSOR_DELAY_GAME . Before the update SENSOR_DELAY_NORMAL resulted in a sampling rate of about 18 samples/seconds. accelerometer.getMaxDelay() still returns 62500, which would be 16 samples/sec. I also tried setting the desired delay directly, when registering the sensor with

How to make a copy of the Android Sensor SensorEvent Object

喜夏-厌秋 提交于 2019-12-08 09:33:35
问题 I have a sparesArray which I use to store & batch SensorEvents by holding onto each sensor typeId and SensorEvent object until a timer fires. SparseArray<SensorEvent> sensorEventMap = new SparseArray<SensorEvent>(); public void onSensorChanged(SensorEvent event) { synchronized (this) { sensorEventMap.put(event.sensor.getType(), event); } } I am having issues where the SensorEvent is getting overwritten in the array before my timer fires, so I'd like to make a copy of the SensorEvent and store

How to make a copy of the Android Sensor SensorEvent Object

杀马特。学长 韩版系。学妹 提交于 2019-12-07 08:23:33
I have a sparesArray which I use to store & batch SensorEvents by holding onto each sensor typeId and SensorEvent object until a timer fires. SparseArray<SensorEvent> sensorEventMap = new SparseArray<SensorEvent>(); public void onSensorChanged(SensorEvent event) { synchronized (this) { sensorEventMap.put(event.sensor.getType(), event); } } I am having issues where the SensorEvent is getting overwritten in the array before my timer fires, so I'd like to make a copy of the SensorEvent and store the copy in the array instead. How can I make a copy of SensorEvent ? I need the whole SensorEvent,

Android SensorManager error in LogCat

南笙酒味 提交于 2019-12-01 22:53:00
问题 I have a problem with the sensor manager and errors in the logcat. When I register the listener with this line : sensorMgr.registerListener(this, sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); I recieve theses lines in the logcat with three errors. 06-07 20:52:42.419: D/SensorManager(9215): ====>>>>>Num Sensor: 1 06-07 20:52:42.419: D/SensorManager(9215): ====>>>>>Num Sensor: 2 06-07 20:52:42.419: D/SensorManager(9215): ====>>>>>Num Sensor: 3 06-07

Android SensorManager error in LogCat

丶灬走出姿态 提交于 2019-12-01 21:01:54
I have a problem with the sensor manager and errors in the logcat. When I register the listener with this line : sensorMgr.registerListener(this, sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); I recieve theses lines in the logcat with three errors. 06-07 20:52:42.419: D/SensorManager(9215): ====>>>>>Num Sensor: 1 06-07 20:52:42.419: D/SensorManager(9215): ====>>>>>Num Sensor: 2 06-07 20:52:42.419: D/SensorManager(9215): ====>>>>>Num Sensor: 3 06-07 20:52:42.419: D/SensorManager(9215): ====>>>>>Num Sensor: 4 06-07 20:52:42.419: D/SensorManager(9215):

Unregistering SensorManager doesn't work

强颜欢笑 提交于 2019-12-01 11:17:33
In my app, I am using the light and proximity sensor to detect phone out of pocket functionality and then unregistering the SensorManager when their detection is complete. But even when the CPU usage by the app shows just 1-2 sec usage, the battery usage always shows my app as no. 1 app in the list which is worrying. I have used the SensorManager.unRegisterListener and also set SensorManager = null, but the situation remains the same. I have read, that due to some bug, the sensors are not unregistered correctly. Any good way to dispose the sensors correctly ? Pls guide. Omkar Ghaisas Updated

Get device angle by using getOrientation() function

别说谁变了你拦得住时间么 提交于 2019-11-30 13:18:28
问题 I was using Sensor.TYPE_ORIENTATION to determine current angle of device but TYPE_ORIENTATION is deprecated on API version 8 . In SensorManager manual it refers to getOrientation() function in order to use TYPE_ORIENTATION . Here is the manual Here is my old code : public void onSensorChanged(SensorEvent event) { Log.d("debug","Sensor Changed"); if (event.sensor.getType()==Sensor.TYPE_ORIENTATION) { Log.d("debug",Float.toString(event.values[0])); float mAzimuth = event.values[0]; float mPitch