Android Gravity sensor sensor programming

Source: Internet
Author: User

Add a handler function when gravity changes
The function dosomething (x, y, z) that is called when the listener is created is a method that is defined by itself.
The listener calls this method when the phone's tilt direction changes.
All we have to do is populate the method to do our own processing when gravity changes.
When x=y=0, the phone is placed in a horizontal position.
When X=0 and Y>0, the top of the phone's horizontal position is greater than the bottom, that is, the general answer to the phone when the phone is in the state.
When X=0 and y<0, the horizontal position of the top of the phone is smaller than the bottom. Mobile phones are rarely in this state.
When Y=0 and x>0, the horizontal position on the right side of the phone is greater than the left side, i.e. the right side is lifted.
When Y=0 and x<0, the horizontal position on the right side of the phone is smaller than the left side, that is, the left side is lifted.
When z=0, the cell phone plane is perpendicular to the horizontal plane.
When z>0, the phone screen is facing up.
When z<0, the phone screen faces down.

Android Gravity sensor sensor programming

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.