Permission To Vibrate

Maybe I’m the last one to know this, but I just ran across an interesting little compatibility issue between android 2.2 and 2.3.4. If you want to vibrate the phone on 2.2, no problem, go for it. Run your app on 2.3, BOOM. The app will crash with a java.lang.SecurityException: Requires VIBRATE permission. Yep, on 2.3 you need to explicitly add permission in your manifest.

<uses-permission	android:name="android.permission.VIBRATE"></uses-permission>

Really guys? Couldn’t you log a warning, and then simply NOT VIBRATE the device?

In my case I was just sending a notification and using the default flags, which happens to to include vibrate, if the user has enabled it.

Notification notification = new Notification(icon, tickerText, when);
notification.defaults |= Notification.DEFAULT_ALL;

By the way, absolutely no mention of this hidden gem in the documentation.

What other breaking changes lie in wait? The adventure continues…..

This entry was posted in Uncategorized. Bookmark the permalink.

Comments are closed.