android-sensors

what's wrong with my sensor monitoring technique?

こ雲淡風輕ζ 提交于 2019-12-09 04:48:41
问题 (please read UPDATE 3 at the end)I'm developing an app that continually works with the sensors of device, works with Accelerometer and Magnetic sensors to retrieve the orientation of device(the purpose is mentioned here). in other words, my app needs to know the orientation of device in Real-time(however this is never possible, so as fast as possible instead, but really as fast as possible !). as mentioned in professional Android 4 Application Development by Reto Meier : The accelerometers

Is it possible to detect motion when screen is off?

你。 提交于 2019-12-09 03:14:08
问题 My app simply need to detect any motion of the device while screen is off. I know that accelerometer is used for this task but it don't work while screen is off in all devices. this is a list of devices http://www.saltwebsites.com/2012/android-accelerometers-screen-off so is there a way of taking accelerometer sensor data while screen is off that works on all devices? or is there a way to detect motion using another sensors? 回答1: Partial Wake Lock is all you need to access accelerometer

How to detect Upside down Orientation in android?

早过忘川 提交于 2019-12-08 20:45:35
问题 In my android app i have panorama image and i am rotating this image according to phones motion using TYPE_ORIENTATION sensor it is working fine for both landscape and potrait. Here is the code for rotation logic. @Override public void onSensorChanged(SensorEvent event) { switch (event.sensor.getType()) { case Sensor.TYPE_ORIENTATION: float[] insideval = getValPoints(); event.values[1]=(float) (event.values[1]*2.8); event.values[2]=(float) (event.values[2]*2.8); setValPoints(event.values

SENSOR_DELAY_GAME: how much is it?

蹲街弑〆低调 提交于 2019-12-08 15:11:18
问题 I'm working on a game and I need to synchronize two player object controlling mechanisms: one is an on-screen touch controller and second is the G-Sensor. On-screen controller must be initialized with a value in seconds, so I need to know how much seconds does SENSOR_DELAY_GAME mean. Thanks in advance. 回答1: I don't think there is a definite answer into your question, in a meaning that this is device depended. Except from that, keep in mind that even if you define a certain delay for your

Change an image on hover without touching the screen in android

点点圈 提交于 2019-12-08 13:14:50
问题 I have a very creative requirement - I am not sure if this is feasible - but it would certainly spice up my app if it could . Premise: On Android phones, if the screen is covered by hand(not touching, just close to the screen) or if the phone is placed over the ear during a call the phone locks or basically it blacks out. So there must be some tech to recognize that my hand is near the screen. Problem: I have an image in my app. If the user points to the image without touching the screen,

How do I delay my SensorListener in onSensorChanged(SensorEvent e) method?

痴心易碎 提交于 2019-12-08 12:08:57
问题 I do get errors that my code increases the code chache capacity so I have added a delay (Thread.Sleep(1000)) and tried also OnPause which unregisters the Listener. public void OnSensorChanged(SensorEvent e) { lock (_syncLock) { newValue = e.Values.Average(); int noteInt1 = Convert.ToInt32(previousValue); int noteInt2 = Convert.ToInt32(newValue); try { OnPause(); Thread.Sleep(1000); if (newValue != previousValue) { _sensorTextView2.Text = string.Format("Note: {0}", newValue); eventnumbers.Add

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 test sensormanager on emulator in Android?

 ̄綄美尐妖づ 提交于 2019-12-08 10:11:59
问题 I am implementing the sensormanager to test if the device moves it should give the accuracy. But the problem is i dont have device to test this code on. Is it possible to test this sensormanager code on Emulator?? Thanks in advance, Aby 回答1: The OpenIntents project has a Sensor Simulator, but I do not know if it works with the current sensor API and current versions of Android. Beyond that, as @Mighter said, no, it is not possible. 回答2: It is possible, you may look at the changes in the code

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

Sensor Activity in android

自古美人都是妖i 提交于 2019-12-08 08:56:13
问题 I am using the following class to read accelerometer data from an android mobile: public class AccelerometerData extends Activity implements SensorEventListener { //variables public AccelerometerData() { mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL); } @Override public void onAccuracyChanged(Sensor