gpt4 book ai didi

android - 在 android 中为通知设置振动、灯光或声音的组合

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:06:59 24 4
gpt4 key购买 nike

我想为用户提供选择 Lights、Sounds 或 Vibration 或这三者的组合的选项,以在 Notification 上发出警报。

在 android 文档中,我看到有一个 DEFAULT_ALL 选项,其中将使用所有三种警报方法。

否则有一个选项可以选择其中任何一个(DEFAULT_LIGHTSDEFAULT_VIBRATEDEFAULT_SOUND)。

有什么方法可以组合SOUNDVIBRATION但没有LIGHTS和其他组合吗?


编辑

Notification.Builder 的(来自 prolink007 的回答)方法 setDefaults(int default) 说:

The value should be one or more of the following fields combined with bitwise-or: DEFAULT_SOUND, DEFAULT_VIBRATE, DEFAULT_LIGHTS.

应该如何使用?

最佳答案

Notification.Builder API 11NotificationCompat.Builder API 1提供了几种不同的方法来设置这些类型的警报。

  • 设置灯光(...)
  • 设置声音(...)
  • 设置振动(...)

The value should be one or more of the following fields combined with bitwise-or: DEFAULT_SOUND, DEFAULT_VIBRATE, DEFAULT_LIGHTS.

未经测试,但我相信如果你想要SOUNDVIBRATIONLIGHTS,你会做这样的事情:

setDefaults(DEFAULT_SOUND | DEFAULT_VIBRATE | DEFAULT_LIGHTS);

关于android - 在 android 中为通知设置振动、灯光或声音的组合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12006724/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com