【发布时间】:2016-03-03 10:30:49
【问题描述】:
我在网上搜索并找到了一些与在 android 通知上设置声音相关的帖子并关注了它们,但在我的情况下,我在 android 通知上获得了默认通知声音。这是我的代码:
builder.setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notification_message));
我也关注了this 的帖子,但没有运气。
供您参考:我已经使用 MediaPlayer 播放了 URI,然后它工作正常。
我的部分代码:
NotificationCompat.Builder builder = new NotificationCompat.Builder(appContext);
builder.setContentTitle(message.notificationTitle);
builder.setContentText(message.notificationSubtitle);
builder.setTicker(message.notificationTitle);
builder.setSmallIcon(R.drawable.ic_action_inbox);
Uri uri = Uri.parse("android.resource://" + appContext.getPackageName() + "/" + R.raw.notification_message);
builder.setSound(uri);
builder.setVibrate(new long[]{1000, 1000, 1000});
builder.build();
谁能解释一下是什么问题。怎么做?我被卡住了:(
【问题讨论】:
-
检查你的日志看看是否有异常信息。
标签: android android-notifications