0
當我收到通知時,是否可以從原始文件夾創建歌曲? 我試過這段代碼讓歌曲「提醒」開始但沒有發生。在通知中製作特定歌曲
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.beatdanger,
"Your friend is in danger!!!", System.currentTimeMillis());
// Hide the notification after its selected
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.sound = Uri.parse("R.raw.alert");
Intent intent1 = new Intent("wael.ilahi.pfe.SMSRECEIVERESULT");
intent1.putExtra("coordination", str);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
intent1, 0);
notification.setLatestEventInfo(context, "Help your friend !!",
str, pendingIntent);
notificationManager.notify(0, notification);
工作:作爲解釋這裏
"android.resource://" + getPackageName() + "/" + R.raw.your_raw_file
:相反,如果你需要得到一個URI存儲在
res/raw/
-directory文件,使用這種模式。另外,LogCat中應該有某種錯誤或異常消息。將其添加到您的問題。 – 2012-04-10 23:06:44否LogCat中沒有錯誤 – 2012-04-10 23:18:53
你檢查了我的答案嗎? – 2012-04-10 23:19:43