Questions tagged [sensormanager]
193 questions
25
votes
4 answers
Turn off screen programmatically when face is close the screen on Android
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?
![](../../users/profiles/2313129.webp)
Solkin
- 856
- 1
- 9
- 15
18
votes
5 answers
Android SensorManager strange how to remapCoordinateSystem
API Demos -> Graphics -> Compass
It works properly only, until you don't change the device natural orientation.
In most phones is the portrait and most 10 inch tablets are the landscape. If you change than need to rotate this with 90 degree. I would…
user529543
14
votes
3 answers
Pedometer (Step Counter)
I am developing a Pedometer Android application to count number of steps taken and using the steps calculate the distance covered and calories burned. I have followed the tutorial
Create a Simple Pedometer and Step Counter in Android and done…
![](../../users/profiles/5974647.webp)
Harry .Naeem
- 1,037
- 3
- 16
- 29
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…
![](../../users/profiles/1859242.webp)
fobus
- 1,567
- 5
- 23
- 44
11
votes
3 answers
How to detect my screen orientation in portrait locked screen in android?
I want to find the camera screen orientation in locked portrait orientation mode, well I am using camera in my fragment class and I have already set my screen orientation as portrait, but the problem I am facing is, when I turn my camera from…
![](../../users/profiles/3899565.webp)
Vicky
- 901
- 1
- 9
- 32
9
votes
3 answers
Android Compass Bearing
I am trying to get the compass bearing in degrees (i.e. 0-360) using the following method:
float[] mGravity;
float[] mGeomagnetic;
public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
…
![](../../users/profiles/1135357.webp)
duncanportelli
- 3,021
- 7
- 35
- 58
7
votes
2 answers
How to know if my SensorManager has a registered Sensor
I'm using a sensor for my Android Application. I register the sensor with a line of code:
mySensorManager.registerListener(this, orientationSensor, SensorManager.SENSOR_DELAY_NORMAL);
I have introduced a line of code to unregister the listener so…
![](../../users/profiles/931724.webp)
chntgomez
- 1,725
- 3
- 16
- 28
6
votes
2 answers
How to get current value of Android's proximity sensor?
Is it possible to get the current value of the Proximity Sensor in Android?
I know that I can use SensorManager and Sensor and register a state changed listener, but I have no need to be notified of every state change, so it would be highly…
![](../../users/profiles/557596.webp)
Nullqwerty
- 1,100
- 20
- 36
6
votes
2 answers
How do I get subsequent timestamps accurate upto 5 micro seconds in android
Below is sample code I am using:
private final SensorManager mSensorManager;
private final Sensor mAccelerometer;
private long prevTime=0;
public SensorActivity() {
mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
…
![](../../users/profiles/3139681.webp)
kapilgm
- 1,620
- 1
- 12
- 22
6
votes
3 answers
Why The altitude is change if it is Evening or Night?
I have this following code :
public SensorEventListener sensorEventListener = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
float pressure_value = 0.0f;
float height = 0.0f;
if…
![](../../users/profiles/4217457.webp)
Leonard Febrianto
- 934
- 2
- 10
- 34
6
votes
3 answers
Galaxy s3 has Temperature sensor?
I am creating a thermometer app in android when I test on Galaxy S3 it shows that
TYPE_AMBIENT_TEMPERATURE NOT Available
TYPE_TEMPERATURE NOT Available
I want to know that Galaxy S3 has above sensors or not? or How I can solve this issue to get…
![](../../users/profiles/3409263.webp)
user3409263
- 117
- 1
- 4
- 11
5
votes
0 answers
Android: Proper interpretation of sensor values
So I've been poring over the SensorEvent documentation trying to get a handle on how to figure out what direction is north, relative to a given axis of the phone. I've drawn a little image that illustrates my conception of how the coordinate system…
![](../../users/profiles/467366.webp)
Paul
- 9,014
- 9
- 41
- 75
5
votes
0 answers
Appcelerator Hyperloop Android - How to use certain Sensor Manager functions which use a pass by reference structure
I'm stepping into Hyperloop for the first time, specifically for Android currently, and although it's going fairly well I've had one issue which I will explain below.
I've successfully been able to get a handle to the Sensor Manager and set up a…
![](../../users/profiles/8002277.webp)
tinypotato
- 51
- 3
5
votes
4 answers
Inconsistent orientation sensor values on Android for azimuth/yaw and roll
I’m having trouble getting good orientation sensor readings. The sensor readings seemed unreliable, so I tested my code against two free sensor test apps (Sensor Tester (Dicotomica) and Sensor Monitoring (R's Software)). I found that while my…
![](../../users/profiles/2158671.webp)
gisking
- 260
- 2
- 3
- 8
4
votes
2 answers
getSensorList() vs. getDefaultSensor() in Android SensorManager
I'm writing a game for Android and want to be able to use the accelerometer for input.
I see two ways of getting a sensor, one way is to use the first element of SensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER) and the other is…
![](../../users/profiles/960524.webp)
P.T.
- 23,368
- 7
- 60
- 92