sensormanager

Android step counter

China☆狼群 提交于 2021-01-29 06:01:05
问题 I am trying to make a simple Android application to count steps. When I run the application the else is called in the onResume method meaning it did not find the sensor. I am testing on a 2016 Samsung J3 running Api 22. I am wondering is the problem in my code or is it that the phone does not have the sensor. If it is the phone is there a workaround for it? public class MainActivity extends AppCompatActivity implements SensorEventListener { private TextView counterTextView; private

How to know if my SensorManager has a registered Sensor

南笙酒味 提交于 2020-01-12 07:48:25
问题 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 it wont be running all time: mySensorManager.unregisterListener(this); So far it works, but i need to register it again when the application resumes. I need to know if my sensorManager has a registered listener so I can registered again or skit it.

Android sensor listener does not get unregistered or sensor still retrieves values

久未见 提交于 2020-01-03 17:40:47
问题 I have some problems with SensorManager.unregisterListener. They are similar with Android, Thread, Cannot unregister SensorEventListener and SensorEventListener doesn't get unregistered with unregisterListener() method. But I could not find my answer! I also followed SensorManager documentation example http://developer.android.com/reference/android/hardware/SensorManager.html#SENSOR_DELAY_UI. The problem is that after the Activity is finished I unregister the listener but the sensor keeps

Android: How does one deal with inaccurate baromters?

孤人 提交于 2020-01-03 17:26:10
问题 I have been using a Samsung Galaxy S3 to work on an app that uses the barometer estimate the user's altitude. I use SensorManager.getAltitude(p0, p), and set p0 equal to the sea-level pressure reported at the nearest airport. I set p equal to the value returned by the barometer. Unfortunately, the altitude returned is systematically 20 meters or so higher than what it actually is. I'm certain that the barometer is returning pressure values that are too low, so SensorManager.getAltitude is

Unregistering SensorManager doesn't work

删除回忆录丶 提交于 2019-12-30 11:12:12
问题 In my app, I am using the light and proximity sensor to detect phone out of pocket functionality and then unregistering the SensorManager when their detection is complete. But even when the CPU usage by the app shows just 1-2 sec usage, the battery usage always shows my app as no. 1 app in the list which is worrying. I have used the SensorManager.unRegisterListener and also set SensorManager = null, but the situation remains the same. I have read, that due to some bug, the sensors are not

Unregistering SensorManager doesn't work

社会主义新天地 提交于 2019-12-30 11:12:04
问题 In my app, I am using the light and proximity sensor to detect phone out of pocket functionality and then unregistering the SensorManager when their detection is complete. But even when the CPU usage by the app shows just 1-2 sec usage, the battery usage always shows my app as no. 1 app in the list which is worrying. I have used the SensorManager.unRegisterListener and also set SensorManager = null, but the situation remains the same. I have read, that due to some bug, the sensors are not

getSensorList() vs. getDefaultSensor() in Android SensorManager

假装没事ソ 提交于 2019-12-13 13:15:53
问题 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 SensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) . The getDefaultSensor doc says it could return a "composite" sensor, so if I want a "raw" sensor I should use getSensorList . Any idea what the difference between a composite or raw sensor is? Does this

Android: where do PackageManager and SensorManager get their information?

落花浮王杯 提交于 2019-12-13 04:43:33
问题 On Android, to find out the available system features you can do something like: PackageManager pm = getPackageManager(); for (FeatureInfo fi : pm.getSystemAvailableFeatures()) { String feature_name = fi.name; if(fi.name == null){ feature_name = "GlEs Version " + fi.getGlEsVersion(); } Log.i("theTag", feature_name + ""); } Similarly, to find out the available sensors you can do something like: SensorManager sensorManager = (SensorManager)getSystemService(SENSOR_SERVICE); List<Sensor> sensor

Android linear acceleration accuracy

倾然丶 夕夏残阳落幕 提交于 2019-12-12 04:07:16
问题 I have an app where I poll the sensors for acceleration data and save the XYZ values to a SQL DB. Codewise it is pretty simple: public void onSensorChanged(SensorEvent event) { sensor = event.sensor; int i = sensor.getType(); if (i == MainActivity.TYPE_ACCELEROMETER) { accelerometerMatrix = event.values; } else if (i == MainActivity.TYPE_GYROSCOPE) { gyroscopeMatrix = event.values; } else if (i == MainActivity.TYPE_GRAVITY) { gravityMatrix = event.values; } else if (i == MainActivity.TYPE

How to set delay of Android Sensors programmatically?

北战南征 提交于 2019-12-11 23:15:21
问题 If there any method to change delay of andriod sensor other using constant like "Normal_Delay, ...". I want to put the delay value as I like. if this is possible ? Actually, I found a solution by using "handler" but it doesn't work. Here is the solution with Handler but it doesn't work: public void registerSensorListener() { String sensorName = PackageManager.FEATURE_SENSOR_ACCELEROMETER; if (mHandlerThread == null) { mHandlerThread = new HandlerThread("sensorThread"); } if (!mHandlerThread