sensor

Android: the range of z-value in the accelerometer sensor are different on different devices

自闭症网瘾萝莉.ら 提交于 2019-12-06 03:55:10
I want to detect if the device is facing up. (Not angled but flat to the ground facing up). On some devices for facing up, z value will return values between 9~10. (Most devices) However, on Nexus 7, for facing up, z value will return values between 6~8. My code was: if(z_value > 9.0) { // device facing up } else { // device is in angled } However, above code doesn't work anymore. Since Nexus7 doesn't reach z_value of 9. How can I detect if the device is facing (entirely) up or not. (not asking z_value > 0) My full code is below: @Override protected void onStart() { super.onStart(); try {

How to get the compass direction from azimuth on Android

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 01:46:13
问题 I have to display which direction the user is pointing the Android device. I am using Sensor.TYPE_ACCELEROMETER , Sensor.TYPE_MAGNETIC_FIELD to get the azimuth, pitch, roll. But I am to able to figure out how to get directions (North, south, east , west,...) from this. Please help Thanks 回答1: To point the north you can calculate a rotation in degrees : float rotation = -azimut * 360 / (2 * 3.14159f); You can see the following compass example which make uses of accelerometer and magnetic field

Help with PROXIMITY_SCREEN_OFF_WAKE_LOCK in Android

允我心安 提交于 2019-12-06 00:30:52
问题 I've enabled the proximity wakelock in my app, and it turns off the screen when the proximity sensor detects something. But there is a problem when the screen wakes back up -- it goes to the lockscreen, not my app. This happens regardless of the time that the screen was off (even if the sensor is cleared after a few seconds). Here's the code I used: int PROXIMITY_SCREEN_OFF_WAKE_LOCK = 32; mProximityWakeLock = pm.newWakeLock(PROXIMITY_SCREEN_OFF_WAKE_LOCK, LOG_TAG); if(!mProximityWakeLock

Android Orientation Sensor Different for Different Devices?

♀尐吖头ヾ 提交于 2019-12-05 23:46:13
I'm developing an Android game that uses the orientation sensor to get the rotation of the device (to roll a ball). I have two devices that I test apps on, one is a Samsung Infuse (phone) and the other is an Asus Eee Pad Transformer TF101 (tablet). The app runs in landscape on both devices. The problem is that on the Eee Pad, the orientation is measured with the device sideways (landscape mode) while the Infuse measures in upright (portrait) no matter what I do. This makes is so the ball moves left when I tilt my Infuse left, but when I tilt the Eee Pad left, the ball moves up or down. I can

Determining north using the android phone

主宰稳场 提交于 2019-12-05 17:09:48
I looked over SensorManager and was still unsure, how do I detect if the phone is looking at true north (or any other direction for that matter). If you are just looking for a sample, the publishers of Professional Android 2 Application Development have all their example code available for download and there is a compass application in chapter 14. 来源: https://stackoverflow.com/questions/2808811/determining-north-using-the-android-phone

Does iPhone allow Light sensors as input?

試著忘記壹切 提交于 2019-12-05 09:22:00
I was just wondering whether iPhone developement allows light sensors to be used, as buttons or action elements?? I found this link online... Possible to use Light Sensor as a Button? [Archive] - Touch Arcade If anyone could shed some light on the issue, I'd appreciate the help? Cheers. Divanshu. An official answer by an Apple rep is on the Apple Dev Forums (login required): There's no supported way to get at the ambient light sensor. If you'd like to see such support added in the future, I encourage you to file a bug describing your requirements. While we may have seen similar requests many

DHT22 Sensor import Adafruit_DHT error

喜欢而已 提交于 2019-12-05 09:02:16
So I've properly attached DHT22 Humidity Sensor to my BeagleBone Black Rev C. I'm running OS Mavericks on my MacBook Pro and I followed the directions provided by Adafruit on how to use my DHT22 The website I used was pretty clear: https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/software-install-updated Also here is the github files I cloned: https://github.com/adafruit/Adafruit_Python_DHT I put in these lines: git clone https://github.com/adafruit/Adafruit_Python_DHT.git cd Adafruit_Python_DHT sudo apt-get upgrade sudo apt-get install build-essential python

SensorTag 2 CC2650 advertising indefinately firmware

怎甘沉沦 提交于 2019-12-05 06:19:08
I want to use a SensorTag 2 so that it is sitting there broadcasting it's data (and, critically connectable over bluetooth) from when it's turned on to when\if I ever turn it off. Out of the box, the tag is set to only advertise over Bluetooth for a few mins which means that when the connection eventually fails or when the device connected to the tag boots etc etc you can't connect again without physically visiting the tag and resetting it. I see there is firmware that the myWeatherCenter people have created that lets the tag work as a weather station by basically setting it to advertise

Recycling sensors from a broken android device using adb

老子叫甜甜 提交于 2019-12-05 04:52:07
问题 I just broke my s3. 3 years ago it was one of the best smartphones. Question How can I get the values of the inertial sensors of the phone via usb? I would like to use the accelerometer, gyroscope, magnetometer, barometer and gps sensors of the device. Let's say that we want to get: the raw acceleration's data along the three axes. I connected the usb cable and ran adb root and adb shell . Ok. root@android:/ # find / -type d -iname "sensors" /sys/devices/virtual/sensors /sys/class/sensors The

Injecting screen_on event to make sensors work when screen is off

独自空忆成欢 提交于 2019-12-05 02:38:37
问题 I am trying to make sensors work when screen is off. It is well known bug. And there is no any soution for this on all phones. I have the hypothesis that i can can cheat kernel if I send(inject) screen_on event while actually the screen will be turned off. Do you have any ideas how can i check my hypothesis and inject such event? 回答1: Why don't you start a background service that monitors the sensors? And then send/use the results back to your application's activities. Your activity will