简体   繁体   中英

Vibrate permission required only on some devices

I'm testing my app that uses the NotificationManager to send up a notification which does a vibration. Currently, I do not have the Vibrate permission in my manifest. I understand the need to have it, but am seeing some weird behavior between devices without having the permission.

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

I mainly test on a Galaxy S4 which allows me to do the vibration, even without having the permission set. It's on Android 4.3. I just tested with a Samsung Galaxy Nexus which generated a Runtime exception when trying to do the vibrate, indicating I didn't have permission. The Nexus is on Android 4.3.

I understand that I should have the permission, but why is it that the S4 didn't seem to care that it lacked the permission? Is it possible that the S4 stock ROM really doesn't care about permissions?

Here was the inner exception generated, for what it's worth:

 Caused by: java.lang.SecurityException: Requires VIBRATE permission
        at android.os.Parcel.readException(Parcel.java:1431)
        at android.os.Parcel.readException(Parcel.java:1385)
        at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:320)
        at android.app.NotificationManager.notify(NotificationManager.java:136)
        at android.app.NotificationManager.notify(NotificationManager.java:109)

You should include this permission.

I tested without problems for Google Nexus 4, but I had to put the permission because other models like HUAWEY and BQ needs it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM