**我无法找到我的错误**
String filepath = getResources() + "raw/" + mp_name;
Uri defaultRintoneUri = RingtoneManager.getActualDefaultRingtoneUri(
getApplicationContext(), RingtoneManager.TYPE_RINGTONE);
final File ringtoneFile = new File(filepath);
final Uri uri = MediaStore.Audio.Media
.getContentUriForPath(ringtoneFile.getAbsolutePath());
final ContentValues content = new ContentValues();
content.put(MediaStore.MediaColumns.DATA,
ringtoneFile.getAbsolutePath());
content.put(MediaStore.MediaColumns.MIME_TYPE, "audio/*");
content.put(MediaStore.Audio.Media.IS_RINGTONE, true);
Uri newUri = getContentResolver().insert(uri, content);
RingtoneManager.setActualDefaultRingtoneUri(
getApplicationContext(),
RingtoneManager.TYPE_RINGTONE, newUri);
*请帮我弄清楚如何完美设置铃声*
答案 0 :(得分:1)
public void pickRingtone(查看视图){ // TODO自动生成的方法。存根
Intent intent = new. Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,
RingtoneManager.TYPE_RINGTONE);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Ringtone");
// for existing ringtone
Uri urie = RingtoneManager.getActualDefaultRingtoneUri(
getApplicationContext(), RingtoneManager.TYPE_RINGTONE);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, urie);
startActivityForResult(intent, 5);
}