Geekband Android #5 Tenth week share

Source: Internet
Author: User

1. Several concepts of the sensor:

What is a sensor?

Through the mobile phone to feel the temperature, humidity, gravity, direction, light and other sensing methods.

Where are the sensors used on the phone?

Sensors are widely used in mobile phones, such as games, shakes, heart rate meters, pedometer and so on.

What are the common sensors?

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);}      



3. Several concepts about lbs:

What is lbs?

It is a location-based service.

Where's the lbs?

, QQ, Mo Mo, Hungry, American Regiment, Ctrip, where to go network and so on.

Mainly used in those areas?

Sign-in, location, navigation, life services around, social, and more.


4.LBS How to use:

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






Geekband Android #5 Tenth week share

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.