hadi
hadi

Reputation: 497

Android do special action while shaking

i want do special action while shaking phone how can do something while shaking ? i want do something until stop shaking by users how can I?

Upvotes: 1

Views: 382

Answers (1)

leocadiotine
leocadiotine

Reputation: 3315

Try what's mentioned here. Add ShakeListener to your project and add ShakeListener.Callback to any Activity:

public class MainActivity extends Activity 
    implements ShakeListener.Callback {

    @Override
    public void shakingStarted() {
        // Code on started here
    }

    @Override
    public void shakingStopped() {
       // Code on stopped here
    }
}

Upvotes: 1

Related Questions