Android:Notification.DEFAULT_VIBRATE是否需要振动权限?

Xan*_*der 10 java android vibration android-notifications android-vibration

有时候我读到了

notification.defaults|= Notification.DEFAULT_VIBRATE;

notification.defaults = Notification.DEFAULT_ALL;

需要振动许可

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

但有时我读到它没有.

哪一个是正确的信息?

Xan*_*der 9

好吧,显然,你确实需要振动许可.谢谢!


Mik*_*ert 5

您可能有兴趣阅读:https : //android.googlesource.com/platform/frameworks/base/+/cc2e849

从4.2.1开始:

通知振动改进:[请勿合并]

  • 当通知作为回退振动(即,因为它们想播放声音但设备处于振动模式)时,这不再需要VIBRATE权限。
  • 另外,如果您的通知使用DEFAULT_VIBRATE,则您也不需要VIBRATE权限。
  • 如果您指定自定义振动模式,则仍然需要VIBRATE权限。
  • 在后备模式下振动的通知使用相同的振动模式,但将来可以轻松更改。
  • 现在,在config.xml中指定了DEFAULT_VIBRATE和后备振动模式。