Skip to content Skip to sidebar Skip to footer

"shake" App To Respond At Any Time

I want my app to start an activity at any time in response to a 'shake' of the phone. Would it be advisable to have a service constantly running in the background that listens for

Solution 1:

Yes, using a service would be the way to go, since your app needs to be running for the SensorEventListener to work.

Check out this answer for some code on how to implement a SensorEventListener (in an activity, but similar code can be used in a service).

Post a Comment for ""shake" App To Respond At Any Time"