How To Set Custom Ringtone To Contact In Android
Here is my code to update contact and set the custom ring tune it is running successfully but it is not working and I'm using API 9 sound = new File(folder,SONG);
Solution 1:
In StackOverflow similar issue Setting contact custom ringtone, how? you would find that answer
I found out how it works. Below you can see the fixed code code:
UricontactData= ContactsContract.Contacts.CONTENT_URI; StringcontactId= contactData.getLastPathSegment(); CursorlocalCursor= managedQuery(contactData, PROJECTION, null, null, null); localCursor.move(120/*CONTACT ID NUMBER*/); Stringstr1= localCursor.getString(localCursor.getColumnIndexOrThrow("_id")); Stringstr2= localCursor.getString(localCursor.getColumnIndexOrThrow("display_name")); UrilocalUri= Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, str1); ContentValueslocalContentValues=newContentValues(); localContentValues.put(ContactsContract.Data.RAW_CONTACT_ID, contactId); localContentValues.put(ContactsContract.Data.CUSTOM_RINGTONE, f.getAbsolutePath()+"/Adventure.ogg"); getContentResolver().update(localUri, localContentValues, null, null); Toast.makeText(this, "Ringtone assigned to: " + str2, 0).show();
Just change the contact id number to the id of the contact you want to change.
Hope it help
Post a Comment for "How To Set Custom Ringtone To Contact In Android"