sensor

How to use Android sensor event to determine if device is facing up or down

混江龙づ霸主 提交于 2019-12-04 22:41:00
问题 I have quite a simple requirement. Assuming a device is standing on its end, perpendicular to the ground, and it is tilted, all I need to determine is whether the phone is tilted forward or back (screen more toward the ground or more toward the ceiling). I know how to read values from the various sensors and I figure that using sensor TYPE_ROTATION_VECTOR is the way forward. All I'm missing is the maths know-how to determine forward or back from the three values it returns. I've read all

yamaha MS-3C sensor on samsung galaxy

混江龙づ霸主 提交于 2019-12-04 20:16:49
I have a samsung galaxy s and i have made an application that make a list of sensor in the phone. That program show me many sensor, but my question is on two of them: MS-3C Magnetic sensor -->type:2 MS-3C Orientation sensor -->type:3 why it say that they are two different sensor? in the sheet of yamaha http://www.yamaha.co.jp/english/product/lsi/magnetic_sensor/ it seems to be a single sensor. Why android report it as two different sensor? it use the same chip to give me two type of data? Sorry for my english Orientation sensor is a virtual sensor that uses the other actual sensors (such as

Android accelerometer difficulties

陌路散爱 提交于 2019-12-04 19:12:45
I'm a beginner in Android game Development, and I developing a small Game. I am facing some difficulties with the Motion Sensor: Accelerometer. this game is in Landscape mode. I want if my phone tilts in right, my character also goes right. ( same thing for left ) And when I stop tilting Character in the game should stop moving. But i don't understand really good the operation of the accelerometer, here is my code: @Override public void onSensorChanged(SensorEvent event) { synchronized (this) { long penchement = (long) (event.values[1]- 0.5); if(penchement>0){ if(penchement>lastUpdate)

How to convert a program that uses SensorListener to SensorEventListener

泪湿孤枕 提交于 2019-12-04 17:16:08
I am creating an application named CompassApp. I have created two classes named Compass.java and Rose.java. This application has been created from a tutorial described in a website and this uses the deprecated version of SensorListener. The class Compass.java is using this deprecated version. The app worked fine when I used the deprecated version. Then I thought to convert my app into the current version that is SensorEventListener. But the rotation of the compass stopped! I'm stuck and don't know what to do. Please help me. Compass.java with deprecated SensorListener interface public class

unable to detect shake event when my phones screen is off in android

天涯浪子 提交于 2019-12-04 15:49:42
问题 In my application I want to detect the shake event and I'm using SensorEventListener, the code is working fine when my activity is running in foreground. But when I press the lock button of the phone to lock the screen, the shake event can't be detected. I have tested my code on the Samsung gts5360. But the same code is working fine on sony ericssion xperia mini pro. Actually my Samsung phone is not detecting the shake events when I leave the device idle for approx. 45 seconds, after locking

Compass and Accelerometer precision

我们两清 提交于 2019-12-04 14:43:01
问题 i made my own application in Android that use compass and accelerometer sensors to display the degrees of rotation and inclination of my device. I initialized all the listener and objects i needed (i followed some tutorials), and now i can catch the degrees as i wished. The problem is that the measures that sensors return aren't accurate. I mean even if i try to round the values of degrees i catch from the sensor, they oscillate between -/+ 7 (or 8) degrees every fraction of a second, even if

Android - mandatory sensors?

隐身守侯 提交于 2019-12-04 13:28:12
Is there a mandatory list for hardware on Android devices (e.g. magnetic field, distance)? If not, which one are common? These things are defined in the Android Compatibility Definition Document (CDD) . Here is the current one. Check out the hardware-sensors section [7.3.]. As far as I can see all sensors are optional. Most devices are equipped with the following sensors: GPS Accelerometer Proximity sensor Magnetic field Light Gravity (from an API viewpoint , some might be the same on a hardware basis) 来源: https://stackoverflow.com/questions/7402062/android-mandatory-sensors

What is the size of CoAP packet?

给你一囗甜甜゛ 提交于 2019-12-04 12:22:33
问题 I'm new for this technology, can somebody help me to know about some doubt? Q-1. What is the size of CoAP packet? (I know there is 4 byte fixed header, but what is the maximum size limit including header, option and payload?) Q-2. Is there any concept for Keep Alive like MQTT? (It works on UDP for how much time it keeps open the connection, is there any default time or it keeps open every time when we send packet?) Q-3. Can we use CoAP with TCP? (Main problem with it CoAP is it works on UDP,

What exactly is a rotation matrix?

大憨熊 提交于 2019-12-04 10:59:35
i have come across this code which uses the phones sensors to get the orientation of the device in degrees along the 3 axes... this value is calculated from a 4x4 matrix called rotation matrix.. so i was wondering what kind of data is stored in the rotation matrix ? the code is similar to the one in this example Android: Problems calculating the Orientation of the Device Stochastically The Wikipedia article about rotation matrices is reasonable. Basically, the rotation matrix tells you how to map a point in one co-ordinate system to a point in a different co-ordinate system. In the context of

Proximity sensor in Swift (from Objective-C)

落爺英雄遲暮 提交于 2019-12-04 08:27:44
I'm a relatively new user to swift and now, I need to take advantage of the proximity sensor of an iPhone. I don't matter the distance, but I want to know when something is near the iPhone. So I found this code in Objective-C that worked, but I need it in Swift. I have tried some ways, but any worked. So here is the code I need: - (void) activateProximitySensor { UIDevice *device = [UIDevice currentDevice]; device.proximityMonitoringEnabled = YES; if (device.proximityMonitoringEnabled == YES) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(proximityChanged:) name:@