【发布时间】:2019-03-21 17:08:26
【问题描述】:
我制作了一个像 Uber 这样的安卓出租车叫车应用。当请求发送给驱动程序时,它会显示为通知,就像其他任何关于 whatsapp 的通知和带有默认弹出通知声音的消息一样。我需要通知声音响起 15 到 20 秒,而不是弹出声音。我该怎么做?
【问题讨论】:
标签: android android-notifications
我制作了一个像 Uber 这样的安卓出租车叫车应用。当请求发送给驱动程序时,它会显示为通知,就像其他任何关于 whatsapp 的通知和带有默认弹出通知声音的消息一样。我需要通知声音响起 15 到 20 秒,而不是弹出声音。我该怎么做?
【问题讨论】:
标签: android android-notifications
尝试设置长度为 15 到 20 秒的铃声文件
//App.appInstance --> Application class instance
Uri uri = Uri.parse("android.resource://" + App.appInstance.getPackageName() + "/" +
R.raw.notification_sound);
NotificationCompat.Builder builder = new NotificationCompat.Builder(App.appInstance, "")
.setSound(uri)
将声音文件放在原始文件夹中
【讨论】:
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Notification mNotification = new Notification.Builder(this)
................setSound(soundUri).........
.build();
【讨论】: