Questions tagged [android-sensors]

Android-sensors tag unites questions that are connected with different hardware sensors that are embedded into Android devices (barometer, accelerometer, magnetometer, microphone, camera and so on)

Sensor Class Reference

1574 questions
12
votes
6 answers

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

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…
eros
  • 4,616
  • 17
  • 48
  • 77
12
votes
3 answers

Calculate true heading correctly in android

My requirement is bearing in like Google maps apps in compass mode (you can see demo when click to current location button twice): In this compass mode, the Maps always rotated by an angle so that bluedot arrow always point to the top screen. But…
NamNH
  • 1,580
  • 12
  • 32
12
votes
4 answers

How to get a phone's azimuth with compass readings and gyroscope readings?

I wish to get my phone's current orientation by the following method: Get the initial orientation (azimuth) first via the getRotationMatrix() and getOrientation(). Add the integration of gyroscope reading over time to it to get the current…
Sibbs Gambling
  • 16,478
  • 33
  • 87
  • 161
12
votes
2 answers

Display Direction of Place with Arrow in Android ListView

I have requirement to show list of some places in Android ListView with the direction of that place. I able to that by finding the angle between the locations but the issue is that My Client required the arrow to be rotated when the device was…
TNR
  • 6,014
  • 3
  • 30
  • 61
12
votes
4 answers

SCREEN_ORIENTATION_LANDSCAPE upside down - Why?

I am using the following code to set orientation locking per user preference: private void doLock(boolean locked) { if (locked) { int o = getResources().getConfiguration().orientation; if (o ==…
an00b
  • 11,048
  • 13
  • 60
  • 97
11
votes
2 answers

How to use Accelerometer to measure distance for Android Application Development

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…
Dr. Arslan
  • 834
  • 1
  • 10
  • 25
11
votes
1 answer

Driving Style Detection using Smartphone Sensors

I want to measure the acceleration (forward and lateral separately) using an android smartphone device in order to be able to analyse the driving behavior/style. My approach would be as follows: 1. Aligning coordinate systems Calibration (no motion…
R. Doe
  • 211
  • 1
  • 5
11
votes
2 answers

Android AllJoyn: Connection with second machine gives error of BusAttachement

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…
Robin Royal
  • 1,540
  • 1
  • 15
  • 28
11
votes
2 answers

How to mock MotionEvent and SensorEvent for Unit Testing in android?

How to unit test android SensorEvent and MotionEvent classes ? I need to create one MotionEvent object for Unit testing. (We have obtain method for MotionEvent that we can use after mocking to create MotionEvent custom object ) For MotionEvent…
codevscolor
  • 2,088
  • 14
  • 29
11
votes
7 answers

what's wrong with my sensor monitoring technique?

(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…
Soheil
  • 1,610
  • 6
  • 31
  • 63
11
votes
3 answers

How to Calculate Height of Android Phone from ground

I am working on a project in which i have to calculate my device height from ground. I have searched all over the internet but could not find any solution. Please, Anyone tell me what to do..??
Saurav
  • 111
  • 1
  • 1
  • 3
11
votes
3 answers

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

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…
Yahor
  • 113
  • 1
  • 1
  • 6
11
votes
4 answers

How can I get the magnetic field vector, independent of the device rotation?

What I want to archieve is a sort of "magnetic fingerprint" of a location. I use the MAGNETIC_FIELD sensor and in the event I get the 3 values for the (unfortunately not further explained) X, Y and Z axis. Problem is, that the values change as I…
Ridcully
  • 22,583
  • 7
  • 66
  • 81
11
votes
4 answers

What is the difference between SENSOR_DELAY_NORMAL, SENSOR_DELAY_GAME, SENSOR_DELAY_UI and SENSOR_DELAY_FASTEST in Android

Can anybody tell me what is the difference between SENSOR_DELAY_NORMAL, SENSOR_DELAY_GAME, SENSOR_DELAY_UI and SENSOR_DELAY_FASTEST in Android sensors. Where should a developer use all these things? What will user feel by using all these?
Prasad
  • 1,295
  • 5
  • 17
  • 31
10
votes
3 answers

android compass seems unreliable

I have been working on a small compass app the past couple of days, and have gotten the code up and running, but it seems that the compass reading is not accurate. After calibrating both phones, my first test that i found this in what that i simply…
ocross
  • 572
  • 1
  • 5
  • 22