The simplest way to listen to a mobile phone shake android

Source: Internet
Author: User

It is often seen that many software have built-in shake functions. Even if it is not obvious that it is a shake, there are many similar functions, such as shake food, shake and add friends,

Of course, you can also shake and add friends,

In fact, it is not difficult to implement it,

Add

Shakelistener. newinstance (this). Start ();

Shakelistener. newinstance (this). setonshakelistener (listener );

Listener

Shakelistener. onshakelistener listener = new shakelistener. onshakelistener (){

Public void onshake (float X, float y, float Z ){

System. Out. println ("Mobile Phone shake ");

}

};

Stop listening

Shakelistener. newinstance (this). Stop ();

Note:

Shakelistener class, which can be found in my download resources.

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.