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
17
votes
5 answers

Get temperature of battery on android

How do I get the temperature of the battery in android?
Christian
  • 21,975
  • 33
  • 117
  • 195
17
votes
1 answer

What is the alternative to android orientation sensor?

Hi I am building a 3D game for Android. I am currently trying to add a sensor to my game that allows the player to tilt the android as its controls. Ideally I would like to use the ORIENTATION sensor, but I noticed it has been deprecated. Does…
user1207381
  • 551
  • 2
  • 6
  • 17
16
votes
2 answers

how to calibrate the orientation sensor in android?

I'm writing an app in Google Android 2.1 that needs to know which direction (n/w/s/e) the device (HTC Hero) is facing. The sensor and its listener are working great, but the values I get from the sensor are totally crappy. e.g. it tells me I'd be…
xenonite
  • 1,631
  • 4
  • 28
  • 43
15
votes
6 answers

Android devices with pressure sensor

Are there any Android devices out there that have a barometric pressure sensor? I know that the android.hardware.Sensor class has a TYPE_PRESSURE constant and the getAltitude method in SensorManager almost mentions atmospheric pressure. So, are…
kasgoku
  • 4,967
  • 5
  • 18
  • 20
15
votes
4 answers

Detect user activity (running, cycling, driving) using Android

Using my Android device how can I detect if the user is walking, cycling or driving? I have checked the Google Fit app. It differentiates between running, cycling and driving. I am puzzled about what algorithms I should use to differentiate between…
Mayur More
  • 793
  • 2
  • 10
  • 34
15
votes
3 answers

SensorEvent.timestamp inconsistency

my application performs in background step counting using the step detector sensor API's introduced in android 4.4.X. It's essential to my app to know the exact time (at least accuracy of a second) each step event has accrued. because I perform…
Tal Kanel
  • 9,855
  • 10
  • 55
  • 93
15
votes
4 answers

Android: Shake Detector too Sensitive

I'm trying to detect a shake - and i'm using the following code, it works very good, but in some devices (Galaxy note 2 for example) it detects the shake too soon (in some cases - when i just hold the phone still) main.java: ShakeListener mShaker =…
Erez
  • 2,550
  • 2
  • 19
  • 27
14
votes
5 answers

How to know if a sensor is present on my Android device?

i would like to know if a sensor (for exemple the accellerometer) is present on my Android device. I am dealing with the SensorManager class. Here is the code I am using: sensorMgr = (SensorManager)…
Miloš
  • 17,005
  • 46
  • 137
  • 240
14
votes
1 answer

Blocked JS deviceorientation devicemotion on Android WebView

I've written a JS SDK for Android WebView that collects device orientation and motion. The SDK listens to deviceorientation and devicemotion events on the window like so: window.addEventListener('devicemotion', (event) =>…
Shlomi Schwartz
  • 11,238
  • 25
  • 93
  • 155
14
votes
3 answers

Get device angle by using getOrientation() function

I was using Sensor.TYPE_ORIENTATION to determine current angle of device but TYPE_ORIENTATION is deprecated on API version 8. In SensorManager manual it refers to getOrientation() function in order to use TYPE_ORIENTATION. Here is the manual Here…
fobus
  • 1,567
  • 5
  • 23
  • 44
14
votes
3 answers

Proximity sensor on Galaxy S4 (Air Gestures)

The new Samsung Galaxy S4 have and interesting new type of gestures called "Air Gesture" that use an infrared sensor to process users hand movement in front of the screen, adding a "pre-touch"/"proximity" event, in which the fingers are detected…
Nifhel
  • 1,940
  • 2
  • 22
  • 38
14
votes
3 answers

Compass in Android

I am trying to program a compass with Android using the accelorometer and the magnetic field sensor, now I am wondering how to get the correct angle for my compass. I read in the values of the accelerometer and of the magnetic field sensor in…
user1809923
  • 1,215
  • 3
  • 12
  • 25
13
votes
1 answer

Android sensor listening when app in background

Is it possible to track motion sensor events on Android continuously, even if the app is not in foreground? If yes - what's the drain on battery? A client asked if it would be possible to write an app that would initiate an action if the person…
Publicus
  • 1,420
  • 5
  • 16
  • 28
13
votes
2 answers

SENSOR_DELAY_GAME: how much is it?

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…
Egor
  • 37,239
  • 10
  • 109
  • 127
12
votes
6 answers

Compass give me crazy data, is calibration needed or it's the sensor broken?

I'm working with android sensor data. My application use SensorManager.getRotationMatrixFromVector( mRotationMatrix , event.values); and it has been working well until this morning, when the rotation matrix started to send a lot of…
vgonisanz
  • 11,352
  • 12
  • 74
  • 123