有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java安卓:doesnotification。默认\u振动是否需要振动权限?

有时候我读到了

notification.defaults|= Notification.DEFAULT_VIBRATE;

notification.defaults = Notification.DEFAULT_ALL;

需要振动许可

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

但有时我读到它不是

哪一个是正确的信息


共 (2) 个答案

  1. # 1 楼答案

    你可能对阅读感兴趣:https://android.googlesource.com/platform/frameworks/base/+/cc2e849

    从4.2.1开始:

    Notification vibration improvements: [DO NOT MERGE]

    • When notifications vibrate as a fallback (that is, because they want to play a sound but the device is in vibrate mode), this no longer requires the VIBRATE permission.
    • As a bonus, if your notifications use DEFAULT_VIBRATE, you don't need the VIBRATE permission either.
    • If you specify a custom vibration pattern, you'll still need the VIBRATE permission for that.
    • Notifications vibrating in fallback mode use same vibration pattern but can be changed easily in future.
    • The DEFAULT_VIBRATE and fallback vibrate patterns are now specified in config.xml.
  2. # 2 楼答案

    显然,你需要振动许可。谢谢