android-sensors

how to detect a metal using magnetic sensor in android phone?

爷,独闯天下 提交于 2019-12-23 14:55:00
问题 I want to detect a metal using magnetic sensor values. i am getting values continuously like x=30.00 ,y=-20.00 ,z=-13.00 now i want to know how to use these values for detecting any metal(mathameticalcalu,formulas) code is sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); // get compass sensor (ie magnetic field) myCompassSensor = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); float azimuth = Math.round(event.values[0]); float pitch = Math.round(event.values[1]);

Android synchronized onSensorChanged?

对着背影说爱祢 提交于 2019-12-23 10:51:39
问题 This is a followup to my question here: Android thread runnable performance I'm having some difficulty wrapping my head around synchronized methods for my app I'm polling the sensors and storing the sensor values into arrays whenever they change float[] accelerometerMatrix = new float[3]; float[] accelerometerWorldMatrix = new float[3]; float[] gyroscopeMatrix = new float[3]; float[] gravityMatrix = new float[3]; float[] magneticMatrix = new float[3]; float[] rotationMatrix = new float[9];

Android AllJoyn: Connection with second machine gives error of BusAttachement

隐身守侯 提交于 2019-12-23 07:06:05
问题 I have developed application for two different sensors. They are working fine separately but when I try to use them togather and create two diffent buses than Alljoyn gives this exception. org.alljoyn.services.common.BusAlreadyExistException: The object has been set previously with a BusAttachment. Below is my source code for connection. Can anyone tell me why I'm having this issue. private void connect() { org.alljoyn.bus.alljoyn.DaemonInit.PrepareDaemon(getApplicationContext()); bus = new

Not able to translate device co-ordinate system to world co-ordinate system on android

我怕爱的太早我们不能终老 提交于 2019-12-22 17:59:02
问题 I have written a small code to convert the device co-ordinates into world co-ordinates by multiplying the Rotation matrix(using getRotationMatrix) and the vector (Ax,Ay,Az) which are the accelerometer values. When I run this, and the phone is static, I get a very fluctuating value for the Z axis(from 9.3 to 10.3) and the other two are 0. However when I give the phone some acceleration in any direction , it still doesn't show any change to those values and they remain zero. This is the part of

How do I get the angle/degree of the phone with sensor/s?

喜你入骨 提交于 2019-12-22 06:27:11
问题 I am trying to get the phone angles by using TYPE_ACCELEROMETER sensor. My goal is to get the angle values only after the phone is tilted. It works, but the problem is when I put my phone facing up on the table, it still says isLandscape = true; private boolean isLandscape; mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE); mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor( Sensor.TYPE_ACCELEROMETER),1000000); private final SensorEventListener

How to unregister a listener from a sensor after stopping the service?

不问归期 提交于 2019-12-22 05:24:31
问题 I'm creating an app that starts a service when "Start" button pressed and stops it when "Stop" button is pressed. in the service, I register a listener for sensor ACCELEROMETER so that I get the accelerometer values of x,y,z axes.. but when I stop my application and unregister the listener from the sensor, even then I get my accelerometer values. Here's the code: // Service public class Accel extends Service { private static Context CONTEXT; private static Sensor sensor; private static

Drawing in air with Android phone

有些话、适合烂在心里 提交于 2019-12-22 04:42:31
问题 I am working on an application to draw in the air with an android phone. As my phone is moving, thanks to the acceletometer, i retrieve the acceleration on each axis ax, ay, az. What I am interested in is: x,y,z. From what I read in forums and in some tutorials, integrating the accelaration twice gives huge errors. So what is the best solution for me to get information on the deplacement of the phone? Thanks for your help. 回答1: Not exactly what you are looking for: Store orientation to an

Android: How do I call a method which is existing in other API Level?

痴心易碎 提交于 2019-12-22 03:16:14
问题 I have application using Android 2.1 which utilize LocationManager to get the altitude. But now, I need to obtain the altitude using SensorManager which requires API Level 9 (2.3). How can I put the SensorManager.getAltitude(float, float) in my 2.1 android application by putting a condition and calling it by a function name (possible in normal Java)? Thank you in advance UPDATE 1 If you have noticed that my application need to be compiled using Android 2.1. That's why I'm looking for a way to

Long running service consumes a lot of battery

China☆狼群 提交于 2019-12-21 11:14:06
问题 I developed an app and some people complains that it takes too much battery, it is the second most consuming process after the screen. However, in some devices it does not consumes that much battery. All the work my app do is in a service. The service is sticky and is running all the time (the android system may kill it when has low resources or pause it when device go to sleep), it has listener to the accelerometer as long as the screen is on, it is not foreground service and does not hold

Long running service consumes a lot of battery

♀尐吖头ヾ 提交于 2019-12-21 11:14:01
问题 I developed an app and some people complains that it takes too much battery, it is the second most consuming process after the screen. However, in some devices it does not consumes that much battery. All the work my app do is in a service. The service is sticky and is running all the time (the android system may kill it when has low resources or pause it when device go to sleep), it has listener to the accelerometer as long as the screen is on, it is not foreground service and does not hold