我正在向我的应用添加notificationCompat,它工作正常,但现在我想将自己的声音添加到通知中,所以,我读到的是:
.setSound(Uri sound);
但是,我不能得到uri,我该怎么做?我的项目中.wav文件应该放在哪里?
答案 0 :(得分:2)
要添加自己的通知声音,请按照以下步骤操作。在您的服务类中编辑。
PendingIntent pendingIntent= PendingIntent.getActivity(getBaseContext(),0, myIntent,Intent.FLAG_ACTIVITY_NEW_TASK);
// myNotification.defaults |= Notification.DEFAULT_SOUND;
myNotification.sound = Uri.parse("android.resource://com.adroid.alarm"+R.raw.airtel_latest);
将声音文件放在原始文件夹中。使用您的包名编辑com.android.alarm。