android-sensors

How to make an accurate compass on android

时光总嘲笑我的痴心妄想 提交于 2019-11-27 05:09:00
问题 my android application shows the direction of a particular place in the world and therefore in needs to get the compass degree. This is the code I've been using to calculate the degrees: public void getDirection() { mySensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE); List<Sensor> mySensors = mySensorManager.getSensorList(Sensor.TYPE_ORIENTATION); if(mySensors.size() > 0){ mySensorManager.registerListener(mySensorEventListener, mySensors.get(0), SensorManager.SENSOR

Reference coordinate system changes between OpenCV, OpenGL and Android Sensor

邮差的信 提交于 2019-11-27 04:22:33
问题 I am working with OpenCV , Android and OpenGL for an Augmented Reality project. As far as I know the coordintate system in OpenGL is The OpenCV coordinate system is: When combining these devices with android sensors how can I do the coordinate system conversions and [R|t] matrix conversion? Is there a good tutorial or documentation were all of this conffusing stuff is explained? 回答1: If you look at the picture, then you see, that the both coordinate systems have the same handednes, but the

Get temperature of battery on android

青春壹個敷衍的年華 提交于 2019-11-27 03:51:51
How do I get the temperature of the battery in android? Ingo Try this: private class mBatInfoReceiver extends BroadcastReceiver{ int temp = 0; float get_temp(){ return (float)(temp / 10); } @Override public void onReceive(Context arg0, Intent intent) { temp = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE,0); } }; then define in your Variable declarations: private mBatInfoReceiver myBatInfoReceiver; and in onCreate: @Override public void onCreate(Bundle b) { super.onCreate(b); setContentView(R.layout.activity_main); // ... // Add this myBatInfoReceiver = new mBatInfoReceiver(); this

How do I get the correct bearing (magnetic orientation) regardless of screen orientation?

帅比萌擦擦* 提交于 2019-11-27 02:27:47
问题 I want to get the current magnetic orientation regardless of the current screen orientation (landscape or portrait). I found this example, but it's not orientation independant, right? And this didn't help me either. I did also read http://android-developers.blogspot.de/2010/09/one-screen-turn-deserves-another.html. This is my current approach with the deprecated way I don't want to use (short): mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION); private SensorEventListener

how can we measure distance between object and android phone camera

橙三吉。 提交于 2019-11-27 01:11:17
问题 I want to calculate the distance between the camera and the recognized object.For this I tried a lot of methods, I tried to find the angle between the object and the camera using accelerometer and then use d = h * tan a h is height of from from the base generally which is 1.4 and i tried to calculate the angle by using get orientation method. Kindly let me know where am I doing wrong. Its been more than 2 days I have been struggling with this requirement. We have looked into various Camera

Calculating distance using Linear acceleration android [duplicate]

我的梦境 提交于 2019-11-26 19:47:15
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Android accelerometer accuracy (Inertial navigation) I am using the following code to calculate the distance. tnew and anew are arraylists containing timestamps and accelerations respectively. double distance=0; double init_vel=0; long time_prev=tnew.next(); while(anew.hasNext()) { float temp_acc=anew.next(); long temp_time=tnew.next(); interval=(temp_time-time_prev)/1000f; //milliseconds to seconds double fin

Turn off screen programmatically when face is close the screen on Android

て烟熏妆下的殇ゞ 提交于 2019-11-26 18:03:41
问题 My app is a dialer and when user holding the phone near his head I need to turn screen off and prevent clicking on the controls - like native Android dialer behavior. What API level I need and how can I do this in right way? 回答1: I found solution by disassembling one very famous VoIP application. This activity after pressing button1 will disable screen and hardware keys when you close sensors. After pressing button2 this function will be switched off. Also, this function required permission:

Convert magnetic field X, Y, Z values from device into global reference frame

China☆狼群 提交于 2019-11-26 17:43:57
When you use TYPE_MAGNETOMETER sensor, you get X, Y, Z values of magnetic field strength in relation to the device orientation. What I want to get is to convert these values into global reference frame, clarifying: user takes the device, measure these values, than rotate the device for some degrees around any axis and gets ~the same values. Please, find similar questions below: Getting magnetic field values in global coordinates How can I get the magnetic field vector, independent of the device rotation? In this answer sample solution is described (it is for linear acceleration, but I think it

Acclerometer Sensor in Separate Thread

我的未来我决定 提交于 2019-11-26 16:38:30
问题 I am saving data from Accelerometer Sensor to Database, but i want to do it in a separate thread. I tried to search it on Internet but most of them uses the same thread. Please help. Things i have Tried: 1) SenSorEventListener sel; Thread A=new Thread(){ public void run() { sel=new SensorEventListener() { @Override public void onSensorChanged(SensorEvent event) { // TODO Auto-generated method stub double Acceleration,x,y,z; x=event.values[0]; y=event.values[2]; z=event.values[2]; Acceleration

How to use Accelerometer to measure distance for Android Application Development

≡放荡痞女 提交于 2019-11-26 15:21:09
I am just a beginner in the application development industry. I know the accelerometer can be used to return the current acceleration along three axis in meters per second squared (m/s2). But I have come to know that an accelerometer can also be use as speedometer. I want to know how I can use accelerometer to determine distance traveled by Android device between points of interest. If it is possible, then how can I implement it? I have seen a similar question "how do I measure the distance traveled by an Iphone using accelerometer" How do I measure the distance traveled by an iPhone using the