sensorManager.registerListener(this,
sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
SensorManager.SENSOR_DELAY_FASTEST);
// Register the Magnetic Field Sensor
sensorManager.registerListener(this,
sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD),
SensorManager.SENSOR
The latest version of the SDK adds the phrase "type_orientation this constant is deprecated. Use Sensormanager.getorientation () instead. This means that the method has been canceled, and the developer uses sensormanager.getorientation () to get the original data.In fact, the Android get direction is obtained by the magnetic field sensor and the accelerometer sensor
This article illustrates how Android uses the sensor sensor to get the direction of a user's movement. Share to everyone for your reference, specific as follows:
Today continue to share a second important sensor, in fact, to get the direction of the things should be very simple, in the previous article to see that there is a type_orientation keyword, you can dir
involves three concepts:Roll: left and right tilt angle, also called Rolling Angle http://baike.baidu.com/view/1769672.htmPitch: front and back tilt, also called the pitch angle http://baike.baidu.com/view/3832041.htmYaw: Left and Right swing, also called yaw angle http://baike.baidu.com/view/1769448.htm
The following code is the source code of/development/samples/compass in android2.3. It demonstrates how to determine the placement posture and orien
Android practice simple tutorial-62nd guns (electronic Sensor exact Compass)
Here we use the sensor provided by the mobile phone to implement a simple small example of the electronic compass. You can learn how to use the SensorManager class, SensorEventListener and its overwriting method.
First, create a layout file:
Good evening ~ Today, I will continue to share with you the second important sensor. In fact, it is very easy to get the direction.ArticleA type_orientation keyword indicates that the device's moving direction can be directly obtained. However, the latest SDK adds the phrase "type_orientation this constant is deprecated. use sensormanager. getorientation () instead. that is to say, this method has been canceled and developers need to use sensormanager
Good evening ~ Today, I will continue to share with you the second important sensor. In fact, it is very easy to get the direction. In the first article, we will see a TYPE_ORIENTATION keyword, indicating that we can directly get the device's direction of movement, however, the latest SDK adds the following sentence: "TYPE_ORIENTATION This constant is deprecated. use SensorManager. getOrientation () instead. that is to say, this method has been cancel
measurement mode, single measurement I used a bit, not very good, so the following main introduction of continuous measurement. Configuration as a continuous measurement is simple, is the above mode register, address 0x02 As you can see, configuring a continuous measurement mode requires only writing the mode register to 0x00. Configuration to continuous, configured as sequential read mode there is a very important place to remember: read XYZ, must read 6 bytes at a time, that is, all r
paramsensor, int paramint) {TODO auto-generated Method Stub}};}First use the superimposed two pictures, one as the pointer, the other as the background four directions LXML file:Android:layout_width= "Match_parent"android:layout_height= "Match_parent" >Android:id= "@+id/compass_img"Android:layout_width= "Wrap_content"android:layout_height= "Wrap_content"Android:layout_centerinparent= "true"android:src= "@drawable/compass"/>Android:id= "@+id/arrow_img
Because the real machine is rotten, after acquiring all the available sensors there is no direction sensor and no magnetic field sensor, so it was aborted and therefore not fully developed, but according to some things in the document added the process of using sensor,First set up a getter in CustomView, which is to ge
Step 1: Create a new project compass and import a compass picture into the res/drawable-hdpi directory
Step 2: Design the UI interface for the application, Main.xml
Step 3:mainactivity.java
Import android.app.Activity;
Import Android.content.Context;
Import Android.hardware.Sensor;
Import android.hardware.SensorEvent;
Import Android.hardware.SensorEventListener;
Import Android.hardware.Se
I just followed the video to learn the operation examples of sensors in Android, and made a very simple compass application using the direction sensor... Sensor functions are rarely used in work projects, so many of them don't know. Now I want to learn more about it as a step-by-step approach...
First paste the software for final operation
The image material use
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.