0
我設置鈴聲,它工作正常,但「.MediaColumns.TITLE」和「.Media.ARTIST」不起作用。我已經設置了鈴聲,然後我檢查。顯示文件名稱而不是「標題名稱」。Android鈴聲管理器「標題」和「藝術家」信息
我的代碼;
public boolean setRingtone(int p, String s) {
String path = Environment.getExternalStorageDirectory().getPath()
+ "/sdcard/media/audio/ringtones/";
String filename = s+'.mp3';
boolean exists = (new File(path)).exists();
if (!exists) {
new File(path).mkdirs();
}
File k = new File(path, filename);
ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath());
values.put(MediaStore.MediaColumns.TITLE, "Title Name");
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");
values.put(MediaStore.Audio.Media.ARTIST, "Ringtones");
values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
values.put(MediaStore.Audio.Media.IS_NOTIFICATION, false);
values.put(MediaStore.Audio.Media.IS_ALARM, false);
values.put(MediaStore.Audio.Media.IS_MUSIC, false);
Uri uri = MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath());
getContentResolver().delete(uri,MediaStore.MediaColumns.DATA + "=\"" + k.getAbsolutePath() + "\"", null);
Uri newUri = getContentResolver().insert(uri,values);
RingtoneManager.setActualDefaultRingtoneUri(SingleListItem.this,RingtoneManager.TYPE_RINGTONE,newUri);
String desc= "Ringtone has been set";
Toast.makeText(getApplicationContext(), desc, Toast.LENGTH_LONG).show();
return true;
}
我擁有這些權限
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
它顯示在手機設置中。我檢查了電話設置,它顯示「文件名」(即字符串s)而不是「values.put(MediaStore.MediaColumns.TITLE,」標題名稱「);」 – 2014-09-25 11:08:40