Advanced Article-Android system: 3. Initial Android phone built-in sensor

Source: Internet
Author: User

After the advent of the second generation of smartphones, the number of sensors in Android phones became more and more.

This note will recognize the type of Android built-in sensors.

If you want to get the name of all the built-in sensors on your Android phone:

ImportAndroid.hardware.Sensor;ImportAndroid.hardware.SensorManager;Importandroid.support.v7.app.AppCompatActivity;ImportAndroid.os.Bundle;Importjava.util.List; Public classMainactivityextendsappcompatactivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_main); Sensormanager Sensormanager=(Sensormanager) Getsystemservice (Sensor_service); List<Sensor> sensors =sensormanager.getsensorlist (Sensor.type_all);  for(Sensor sensor:sensors) {System.out.println (Sensor.getname ()); }    }}

Operation Result:

07-14 23:58:48.148 11693-11693/bhu.com.myapplication i/system.out:lis3dh07-14 23:58:48.148 11693-11693/ Bhu.com.myapplication i/system.out:ak896307-14 23:58:48.148 11693-11693/bhu.com.myapplication i/system.out: orientation07-14 23:58:48.148 11693-11693/bhu.com.myapplication i/system.out:bmp18007-14 23:58:48.148 11693-11693/ Bhu.com.myapplication i/system.out:isl2902807-14 23:58:48.148 11693-11693/bhu.com.myapplication i/system.out: isl2902807-14 23:58:48.148 11693-11693/bhu.com.myapplication i/system.out:l3gd2007-14 23:58:48.148 11693-11693/ Bhu.com.myapplication i/system.out:bmp18007-14 23:58:48.148 11693-11693/bhu.com.myapplication i/system.out: gravity07-14 23:58:48.148 11693-11693/bhu.com.myapplication i/system.out:linear Acceleration07-14 23:58:48.148 11693-11693/bhu.com.myapplication i/system.out:amd07-14 23:58:48.148 11693-11693/bhu.com.myapplication I/ system.out:rmd07-14 23:58:48.148 11693-11693/bhu.com.myapplication i/system.out:vmd07-14 23:58:48.148 11693-11693/ Bhu.coM.myapplication i/system.out:rotation vector07-14 23:58:48.148 11693-11693/bhu.com.myapplication I/System.out: Rotation Vector sensor07-14 23:58:48.148 11693-11693/bhu.com.myapplication i/system.out:gravity Sensor07-14 23:58:48.148 11693-11693/bhu.com.myapplication i/system.out:linear acceleration Sensor07-14 23:58:48.148 11693-11693 /bhu.com.myapplication i/system.out:orientation sensor07-14 23:58:48.148 11693-11693/bhu.com.myapplication I/ System.out:Corrected Gyroscope sensor07-14 23:58:48.148 11693-11693/bhu.com.myapplication i/system.out:bmp180

I used the test machine is Xiaomi 2s, the above operation results print out the millet 2s built-in all sensors.

Advanced Article-Android system: 3. Initial Android phone built-in sensor

Related Article

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.