我知道如何更改手机铃声,也知道如何获取联系人,但是如何为特定联系人设置铃声?
那么我该如何使用该方法:ContactsContract.Contacts.CUSTOM_RINGTONE
?
我试过这样:
Uri contactUri = ContactsContract.Contacts.CONTENT_URI;
String[] PROJECTION = new String[] {
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.HAS_PHONE_NUMBER,
};
String SELECTION = ContactsContract.Contacts.HAS_PHONE_NUMBER + "='1'";
Cursor contacts = managedQuery(contactUri, PROJECTION, SELECTION, null, null );
while (contacts.moveToNext())
{
String Name=contacts.getString(contacts.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
}
String str1 = contacts.getString(contacts.getColumnIndexOrThrow("_id"));
Uri localUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, str1);
ContentValues localContentValues = new ContentValues();
localContentValues.put(ContactsContract.Contacts.CUSTOM_RINGTONE,
f.getAbsolutePath()+"/Adveture.ogg");
MainActivity.this.getContentResolver().update(localUri, localContentValues, null, null);
但它不起作用。