android-sensors

Android changing brightness using sensor

﹥>﹥吖頭↗ 提交于 2020-01-07 02:42:26
问题 I have an app through which I can change the brightness of the device manually. I want to do that using the sensor. What code do I have to add? Also what changes I have to made in the manifest? Here it is my code: package com.example.brightnessdemo; import android.os.Bundle; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.provider.Settings.System; import android.app.Activity; import android.content.ContentResolver; import android

onSensorChanged in android continuously getting triggered in emulator

隐身守侯 提交于 2020-01-05 15:27:28
问题 I am using ACCELEROMETER sensors and have registered a listener for the same via mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mAcceleratorSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mSensorManager.registerListener(this, mAcceleratorSensor , SensorManager.SENSOR_DELAY_NORMAL); This is how my onSensorChanged looks like @Override public final void onSensorChanged(SensorEvent event) { int sensorType = event.sensor.getType(); switch(sensorType

onSensorChanged in android continuously getting triggered in emulator

99封情书 提交于 2020-01-05 15:27:03
问题 I am using ACCELEROMETER sensors and have registered a listener for the same via mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mAcceleratorSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mSensorManager.registerListener(this, mAcceleratorSensor , SensorManager.SENSOR_DELAY_NORMAL); This is how my onSensorChanged looks like @Override public final void onSensorChanged(SensorEvent event) { int sensorType = event.sensor.getType(); switch(sensorType

Android camera onpreviewframe callback and rotation sensor callback synchronization

这一生的挚爱 提交于 2020-01-04 05:38:05
问题 I have been developing an android app which requires camera preview data for each frames,with addition to that I want pitch (Angle) values (From Rotation sensor) while capturing frame.I want to map the pitch values while capturing frames in real time, for now ,I have been mapping the pitch values in onpreviewframe, but I am not getting the correct results because of delay due to frame getting delivered to onpreviewframe callback. I have registered the previewcallbackwithbuffer callback to get

Android getOrientation() returns azimuth, positive or negative?

大城市里の小女人 提交于 2020-01-04 04:26:06
问题 Assumption : the phone is held flat (parallel with the ground). I am using getRotationMatrix() and getOrientation (float[] R, float[] values) to get the azimuth. Under this assumption, the azimuth is simply values[0] . The documentation says: All three angles above are in radians and positive in the counter-clockwise direction. Then I checked, when my phone's y axis points to the North , the azimuth is indeed 0 . However, here comes the problem: when my phone's y axis points to West , i.e. I

Android sensor listener does not get unregistered or sensor still retrieves values

久未见 提交于 2020-01-03 17:40:47
问题 I have some problems with SensorManager.unregisterListener. They are similar with Android, Thread, Cannot unregister SensorEventListener and SensorEventListener doesn't get unregistered with unregisterListener() method. But I could not find my answer! I also followed SensorManager documentation example http://developer.android.com/reference/android/hardware/SensorManager.html#SENSOR_DELAY_UI. The problem is that after the Activity is finished I unregister the listener but the sensor keeps

Android Convert device coordinate system to “user” coordinate system

痴心易碎 提交于 2020-01-03 12:26:29
问题 My question is similar to Changing sensor coordinate system in android I want to be able to compare a user's movements with each other regardless of device orientation. So that when the users holds out the phone in portrait orientation and bends his arm, acceleration readings are the same as when he holds out his phone in landscape and then bends his arm in the same direction. This is what I call the "user" coordinate system. It is different from the world coordinate system since it should

Changing sensor coordinate system in android

≡放荡痞女 提交于 2020-01-03 06:33:41
问题 Android provides sensor data in device coordinate system no matter how it is oriented. Is there any way to have sensor data in 'gravity' coordinate system? I mean no matter how the device is oriented I want accelerometer data and orientation in coordinate system where y-axis points toward the sky, x-axis toward the east and z-axis towards south pole. I took a look at remapCoordinateSystem but seems to be limited to only swapping axis. I guess for orientation I will have to do some low level

What happens when onSensorChanged() in called before it can finish the current execution?

流过昼夜 提交于 2020-01-03 04:20:10
问题 This is my function. public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_LINEAR_ACCELERATION) { //DO A JOB... } } My question is what happens if onSensorChanged() is called while it is finishing the current job? 回答1: If onSensorChanged gets called again while the previous sample is being worked on then onSensorChanged will be working on two samples at once which may be a problem for whatever is happening with the end result of the calculation. I believe

Detect horizontal and vertical movement of the Smartphone on a table

混江龙づ霸主 提交于 2020-01-03 03:39:06
问题 I'm trying to write a small android game where the phone is placed on the table. On the screen there is a ball, which the user control its movement by moving the phone. Along all the game the user won't lift the phone from the table. At the beginning the ball will placed in the middle of the screen: Pushing the phone from the user: should move the ball toward the top of the smartphone screen: And from the current position of the ball, moving the phone back to the user, and to the right: will