我有我至少每天被浪费努力使这项工作。 我想打,一旦收到通知我放在资源/原材料的MP3文件。 我不知道如何得到URI。 我的问题,请有:
1.To玩你必须把它放在资源/原材料,也可以是还资产/该Xamarin的Android项目下听起来自定义文件。
2.How做我正确地得到URI基于mp3文件驻留的位置。
这是我的代码:
private void createNotificationChannel()
{
var channelName = GetString(Resource.String.noti_chan_urgent);
var channelDescription = GetString(Resource.String.noti_chan_urgent_description);
// set the vibration patterm for the channel
long[] vibrationPattern = { 100, 200, 300, 400, 500, 400, 300, 200, 400 };
// Creating an Audio Attribute
var alarmAttributes = new AudioAttributes.Builder().SetUsage(AudioUsageKind.Alarm).Build();
// Create the uri for the alarm file
var alarmUri = Android.Net.Uri.Parse("MyApp.Android/Resources/raw/alarm.mp3"); // this must be wrong because its not working
// create chan1 which is the urgent notifications channel
var chan1 = new NotificationChannel(PRIMARY_CHANNEL_ID, channelName, NotificationImportance.High)
{
Description = channelDescription
};
// set the channel properties
chan1.EnableLights(true);
chan1.LightColor = Color.Red;
chan1.EnableVibration(true);
chan1.SetVibrationPattern(vibrationPattern);
chan1.SetSound(alarmUri, alarmAttributes);
chan1.SetBypassDnd(true);
chan1.LockscreenVisibility = NotificationVisibility.Public;
var manager = (NotificationManager)GetSystemService(NotificationService);
manager.CreateNotificationChannel(chan1);
}
}