0
我试图将我的/storage/sdcard0/Ringtones
上存储的铃声(mp3文件)设置为我希望的联系人。在运行应用程序时,铃声会保存,当我打开该联系人时,我可以看到它已列出。但是,当该联系人呼叫时。联系人铃声设置,但android.process.phone在该联系人调用时死亡
我没有得到调用和下面的消息出现在我的屏幕上: process com.android.phone stops.
下面是我使用的铃声设置为联系人的代码 -
Nb: K is the File object which has the filename and path for the .mp3 clip
String str1 = c.getString(c.getColumnIndexOrThrow("_id"));
Uri localUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, str1);
ContentValues localContentValues = new ContentValues();
localContentValues.put(ContactsContract.Data.RAW_CONTACT_ID, contactId);
localContentValues.put(ContactsContract.Contacts.CUSTOM_RINGTONE, k.getAbsolutePath());
getContentResolver().update(localUri, localContentValues, null, null);
logcat的错误,当联系电话:
01-16 15:27:09.632: E/AndroidRuntime(24282): FATAL EXCEPTION: main
01-16 15:27:09.632: E/AndroidRuntime(24282): java.lang.NullPointerException
01-16 15:27:09.632: E/AndroidRuntime(24282): at com.android.phone.Ringer.isValidRingtoneURI(Ringer.java:742)
01-16 15:27:09.632: E/AndroidRuntime(24282): at com.android.phone.CallNotifier.onQueryComplete(CallNotifier.java:2079)
ContentValues.put(String,Uri);不存在。正确的事情是uriOfRt.toString() –