3
我試圖更改通知的默認聲音,我這樣做:列出所有可用的通知鈴聲Android中
private void showNotification(Context context, String reminderid, String title, String shortinfo, String longinfo)
{
mNM = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
NOTIFICATION=Integer.parseInt(reminderid);
Notification notification = new Notification(R.drawable.icon, title,
System.currentTimeMillis());
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
new Intent(context, RemindersActivity.class).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
notification.setLatestEventInfo(context, shortinfo,
longinfo, contentIntent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.sound = Uri.withAppendedPath(Audio.Media.INTERNAL_CONTENT_URI, "6");
notification.defaults |= Notification.DEFAULT_VIBRATE;
mNM.notify(NOTIFICATION, notification);
}
但是你可以看到,我給號ID爲「6 「對於URI.withAppendedPath()
,我需要列出用戶的所有可用通知鈴聲,並讓他選擇,我將通過他選擇的ID而不是」6「。
這裏谷歌表示:
在這種情況下,媒體文件(「6」)是已知的,附加到所述內容URI的確切ID。如果您不知道確切的ID,則必須使用ContentResolver查詢MediaStore中可用的所有媒體。有關使用ContentResolver的更多信息,請參閱Content Providers文檔。
我該怎麼辦,他們說什麼(請注意,我從來沒有與內容提供商或解算的了)?並給用戶選擇鈴聲的選項,如在手機設置中選擇它?
在此先感謝。
我知道這一點,但我不希望選擇自定義音效,我想要選擇其中一種默認聲音,例如轉到android中的設置並更改通知聲音。 –