- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图通过在原始文件夹中添加 .wav 文件来产生两种类型的自定义通知声音,当像工作这样的通知出现时它会产生与工作相关的通知声音,在其他情况下如果像消息这样的通知出现它会产生消息相关的通知声音。
如果要在高端设备中获取通知,我会设置 channel ,但在创建 channel ID 后,当通知出现时,我会收到相同的通知声音,这取决于首先出现的通知类型。
onMessageReceived
String sound = data.get("sound");
Uri soundUri = Uri.parse("android.resource://" + getPackageName() + "/raw/" + sound);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, getString(R.string.default_notification_channel_id))
.setSmallIcon(getNotificationIconId())
.setContentTitle(title)
.setContentText(messageBody)
.setAutoCancel(true)
.setOnlyAlertOnce(true)
.setSound(soundUri)
.setContentIntent(pendingIntent)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(messageBody));
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O && notificationManager != null) {
int importance = android.app.NotificationManager.IMPORTANCE_HIGH;
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION)
.build();
NotificationChannel mChannel = new NotificationChannel(
getString(R.string.default_notification_channel_id), Constants.NOTIFICATION_CHANNEL_NAME_MESSAGE, importance);
mChannel.setSound(soundUri,audioAttributes);
notificationManager.createNotificationChannel(mChannel);
}
if (notificationManager != null) {
notificationManager.notify(messageId, notificationBuilder.build());
}
list
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/default_notification_channel_id"/>`enter code here`
最佳答案
您需要创建两个通知 channel ,每个 channel 对应每个声音,并根据您要再现的声音分配 channel ID。在 documentation 中进行了解释 channel 一旦创建就无法修改。
关于Android 多种提示音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54086299/
我是 Arduino 的新手(因为这个周末我必须学习它来完成一个学校项目)并且我无法让我的压电扬声器为闹钟发出声音。当草图运行时,一切正常。 LED 闪烁,但蜂鸣器不发声,这很奇怪,因为 LED 和蜂
我想知道是否有人遇到过在 iPhone SDK 中生成铃声的方法。我正在尝试生成 DTMF 音调,但似乎找不到任何实质性内容。我还希望能够指定播放音调的时间(即模拟按住按钮而不是简单地按下按钮....
我正在尝试制作一个可以在 Octave 音阶中水平滚动的钢琴应用程序。下面是另一个我尝试做的钢琴应用程序的示例。箭头在钢琴上滚动 Octave 。我已经了解了scrollview,但是似乎只允许通过滑
我正在我的 Android 应用程序中使用文本转语音 - TTS。我已经粘贴了下面的代码。TTS 工作正常,但是它说的语音/文本不是很清楚。它说的真的快速,以至于它不是完全可以理解的.. 我尝试设置
我正在调用一个带有号码的通话应用程序,然后通过 发送 dtmf 音 String number = "tel:+1234567,890#"; Intent c1 = new Intent(androi
我正在开展一个项目,该项目要求我的应用能够在通话期间以语音的上行链路频率发送 DTMF 音。 我的两个条件是: 我们不使用定制的 Android 平台 我们不需要root手机 我花了几天时间做功课,并
我需要制作一个IVR -auto dialer应用程序,它 => 调用免费电话 => 然后选择一个选项继续 => 然后输入一些代码 => 然后几秒钟后(一些广告/说 30 秒)需要输入另一个选项 前三
在我的 Twilio基于应用程序我通过 Twilio REST 创建拨出电话API。 当目标方响应时,我将他/她放到最近创建的 session 中。 在让他/她参加 session 之前,如何播放特定
Twilio 未从 Skype 检测到我的 DTMF 音。 我们用 twilio 建立了一个 IVR 系统,客户必须输入一个 7位客户编号。 我们的一些客户使用 voip 电话, 因此我们需要确保 t
我想在我的应用程序中以编程方式发送DTMF 铃声。在搜索时我找到了一个方法 public void playDtmfTone(字符数字) 这是 google 在 android 中发送 DTMF 的新
我读过一些有关 Android 中 DTMF 的文章。我想不可能通过流式传输 .wav 文件(或其他格式)进行自动电话调用并检测其他人(调用接收者)的输入。 我想制作一个应用程序来调用我/或其他人,并
我是一名优秀的程序员,十分优秀!