1. Several concepts of the sensor:
Sensor_type_accelerometer //acceleration
Sensor_type_magnetic_firld //Magnetic
Sensor_type_orientation //direction
Sensor_type_gyroscope //Gyroscope
Sensor_type_light //Light Sensing
Sensor_type_pressure //pressure
Sensor_type_temperature //temperature
Sensor_type_proximity //Close
Sensor_type_gravity //Gravity
Sensor_type_linear_acceleration //Linear acceleration
Sensor_type_rotation_vector //rotation vector
2. How to use the sensor:
The first step is to get the Sensormanager object = (sensormanager) getsystemservice (sensor_service);
Second, get the Sensor object msensormanager. Getdefaultsensor . Type_orientation);
@Override //Step three, register at Onresume onresume() { Super. Onresume (); msensormanager. Registerlistener (, Sensormanager. SENSOR_DELAY_UI);}
//Fourth step, rewrite onsensorchanged,onaccuracychanged two methods@OverridePublic voidonsensorchanged(Sensorevent event) {if(event.sensor. GetType () = = Sensor.type_orientation){//Determine which sensing mode to use floatdegree =-event.Values[0]; Rotateanimation rotateanimation =NewRotateanimation (//Use a rotating animation rotateanimation Mstartdegree, Degree, Animation.relative_to_self, 0.5f, Animation.relative_to_self, 0.5f ); Rotateanimation.setduration ( -); //Give a spin duration Mimageview. Startanimation (Rotateanimation); Mstartdegree= Degree; }}@OverridePublic voidonaccuracychanged(Sensor sensor, intAccuracy) {}
@Override //Fifth step, logout at OnPause onPause() { Super. OnPause (); Msensormanager. Unregisterlistener (this);}
A, to the Baidu map to apply for a new version of key, the old version can also be used.
Http://developer.baidu.com/map/geosdk-android-key.htm
b, add permissions in Manifes, specific reference
<!--Use the permissions you need to locate--
<permission android:name= "Android.permission.BAIDU_LOCATION_SERVICE" >
</permission>
<uses-permission android:name= "Android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name= "Android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name= "Android.permission.READ_LOGS"/>
<uses-permission android:name= "Android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
Add the service required to locate in the manifest
<service
Android:name= "COM.BAIDU.LOCATION.F"
Android:enabled= "true"
android:process= ": Remote" >
</service>
Add the key to your lock application in the Application tab
<meta-data
Android:name= "Com.baidu.lbsapi.API_KEY"
Android:value= "15xihyx7bjnpauvragade2wo"/>
C, in the activity of the implementation of code, specific reference
http://blog.csdn.net/xiaanming/article/details/11380619