Make Your Android Phone Vibrate
So I got this good suggestion from one user’s comment: when shake to shuffle, make the phone vibrate.
It’s actually a very simple 2-step operation, but android developer site wasn’t very clear about. Here’s how I did it:
Add permission in AndroidManifest.xml file like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.VIBRATE" />
……
</manifest>
In your program when you want the phone to vibrate:
// [...]
How to detect shake motion on Android phone
When I was implementing the shake-to-shuffle feature in Pair-Up game, I googled for a similar code-snippet but didn’t have much luck. Eventually I came across this hidden code in Android Developer Guide which talks about using the phone motion sensor to program:
http://developer.android.com/guide/samples/ApiDemos/src/com/example/android/apis/os/Sensors.html
Alas! It can be done! But I just need a very simple function to [...]


Recent Comments