我有一个应用程序,其中包括尝试为单个联系人设置特定声音。一切正常,当您查看联系信息时,它会将声音显示为联系人的铃声,但是当联系人呼叫时,默认铃声响起。任何人都可以解释什么是错的吗?
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
switch (requestCode) {
case CONTACT_PICKER_RESULT:
Uri contactData = data.getData();
String contactId = contactData.getLastPathSegment();
Cursor localCursor = managedQuery(contactData, null, null, null, null);
localCursor.moveToFirst();
String str1 = localCursor.getString(localCursor.getColumnIndexOrThrow("_id"));
String str2 = localCursor.getString(localCursor.getColumnIndexOrThrow("display_name"));
Uri localUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, str1);
ContentValues localContentValues = new ContentValues();
localContentValues.put(ContactsContract.Data.RAW_CONTACT_ID, contactId);
localContentValues.put(ContactsContract.Data.CUSTOM_RINGTONE, ringtonePath);
getContentResolver().update(localUri, localContentValues, null, null);
Toast.makeText(this, "Ringtone assigned to: " + str2, 0).show();
break;
}