Skip to content Skip to sidebar Skip to footer

Start New Activity Using Onshake Method

I'd like to start new activity by using onShake method. Everything is ok but when new activity starts, onShake command is still possible (when i shake my phone 5 times, new activit

Solution 1:

Use unregisterListener() in onPause().

Solution 2:

Use an instance variable(a boolean) and keep it set to false initially. When onShake() is called the first time, check if it is false before starting the new activity. Then change it to true and start the activity. The next time the onShake() method gets called, your activity will not start since your instance variable is now set to true.

Post a Comment for "Start New Activity Using Onshake Method"