我做了一个像Uber这样的安卓打车应用。当请求发送到驱动程序时,它会像whatsapp的任何其他通知一样显示为通知,并使用默认弹出通知声音显示消息。我需要通知声音响起15到20秒,而不是弹出声音。我该怎么做呢?
发布于 2019-03-21 17:08:26
尝试设置铃声文件的长度为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)将声音文件放在raw文件夹中
发布于 2019-03-21 16:15:29
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Notification mNotification = new Notification.Builder(this)
................setSound(soundUri).........
.build();https://stackoverflow.com/questions/55276015
复制相似问题