android-sensors

How to read the pressure sensor?

老子叫甜甜 提交于 2020-04-28 22:42:06
问题 Physical home button press can be detected easily on most of the devices: ... public class ExampleAccessibilityService extends AccessibilityService { ... @Override protected boolean onKeyEvent(KeyEvent event) { if (event.getKeyCode() == KEYCODE_HOME && event.getAction() == ACTION_DOWN) Log.d("Example", "The home key is pressed."); return super.onKeyEvent(event); } } But the code above doesn't work on some devices that have a pressure-sensitive virtual home button. I suppose these Samsung

How to use onAccuracyChanged function in sensors

不打扰是莪最后的温柔 提交于 2020-01-26 02:54:10
问题 I am making an app in which am using two sensors. TYPE_MAGNETIC_FIELD TYPE_GRAVITY I initialized the respective sensors and then in onSensorChanged function, am fetching the data and doing the calculations on the same. I have one simple question, how can I use onAccuracyChanged function to filter out data? I want the data with medium and high accuracy!! I printed basic statements to see what kind of accuracy am getting while debugging the app. Code : `@Override public void onAccuracyChanged

What is the working mechanism of SENSOR_TYPE_GRAVITY to get its data? - Android

馋奶兔 提交于 2020-01-24 10:01:10
问题 I have a 3-D acceleration vector (a, b, c) obtained from an Android phone accelerometer. I wish to calculate the angle between this vector (a, b, c) and the gravity vector, which points exactly downwards. I notice that in Android, there is a way of getting gravity vector under the context of the phone coordinate system instead of the world coordinate system. By simply use sensor type SENSOR_TYPE_GRAVITY , I can get the 3-D gravity vector (d, e, f). Since both vectors are under the same

Block emulators in android application

情到浓时终转凉″ 提交于 2020-01-15 11:17:12
问题 For the security purpose, I want to block emulator to use my app. I do not want my app to be installed on any emulator like genymotion,bluestack,droidx etc... I have an app where we have offer wall which contains no of android app, that use can install and earn points. Once they earn some points then they can withdraw using paypal account. Now the problem is some of the users are installing it via proxy or emulator.they are earning money like anything by using proxy or emulator.. Please help.

Android accelerometer angle calculation

老子叫甜甜 提交于 2020-01-14 20:08:05
问题 Can anyone give any idea to calculate the angle by which a compass needle should be rotated to point in the direction of gravity from accelerometer x, y, z values? 回答1: I think X should be 0 and y should be positive while z is near 0 for the compass to point down towards earth. (Which means the phone is held vertical). In general, from the 0 angle, the compass' angle should be something like float accelerometerMaxRange = 10; // This is NOT right, but it's a good value to work with float

How to retrieve high quality compass orientation (as in Google Maps)?

妖精的绣舞 提交于 2020-01-12 18:57:23
问题 All of the guides to getting compass orientation in Android I've found have a bug: when you hold the phone in portrait mode and "look" above the horizon, the compass arrow turns 180 degrees from the correct direction. Google Maps orientation indicator doesn't have this problem. Another nice thing that Google Maps have is that they somehow estimate compass accuracy. Any idea how they do this? 回答1: Error you ask is caused because of Euler angles or called Gimbal Lock. To solve very high angle

Capture image automatically like 360 Panorama

和自甴很熟 提交于 2020-01-11 09:14:11
问题 I am working on the application which is similar to Panorama app.I want to capture the image automatically when device moved from left to right like 360 panorama app works.After few research,I came to know that Sensor and thread can be useful for that and I have seen some examples of sensor here.But I couldn't understand about how to use sensor for my purpose.I also could not find any tutorial related to sensor with camera for auto capturing image.If anybody have any idea or example regarding

A method for waiting for sensor data

空扰寡人 提交于 2020-01-11 07:13:59
问题 I have a class which initiates a sensor listener when it is started. This listener writes the latest sensor value to a variable when an event is triggered. The class goes on to do some logic, and at some point, will check this variable and proceed depending on the value. My issue is that there's no guarantee that there is any value when the variable is read, since Android sensor listeners only trigger an event when the sensor value changes (and don't necessarily trigger an event as soon as

Having trouble reading heart rate sensor from Moto 360 - Android Wear

白昼怎懂夜的黑 提交于 2020-01-10 15:41:37
问题 Has anyone successfully read the heart rate sensor from the Moto 360? mSensorManager = ((SensorManager)getSystemService(SENSOR_SERVICE)); mHeartRateSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE); I am getting an error that states "SensorManager﹕ sensor or listener is null" I know the Gear Live uses a different ID other than Sensor.TYPE_HEART_RATE...I'm wondering if that's the case with the Moto 360. I tried a sensor value of 65538 which reports itself as a "Wellness Sensor"

finding speed of device movement

杀马特。学长 韩版系。学妹 提交于 2020-01-07 02:44:08
问题 I need to find velocity of a device(Samsung Galaxy s3). I've now read quite a lot of stackoverflow questions concerning it, but still confused as for what I should use. My observations so far: 1) Somebody did this to find velocity from accelerometer sensor's data. But in my case the device's movement will not have constant slope or straight trajectory. 2) Integration will give much drift. 3) Kalman filtering can be used but it's hard to implement and CPU consuming 4) Complementary filter can