问题
I'm trying to play a ringtone using a ContentProvider, this works great using a contact ringtone (openFile | openAsset is called within my content provider)
final ContentValues values = new ContentValues();
values.put(ContactsContract.Contacts.CUSTOM_RINGTONE, MY_CONTENT_PROVIDER_URI.toString());
final Uri uri = Uri.withAppendedPath(
ContactsContract.Contacts.CONTENT_URI,
Uri.encode(String.valueOf(contact)));
mContext.getContentResolver().update(uri, values, null, null);
However won't work for the phone ringtone, my ContentProvider won't be called and the system default ringtone will be played instead. Only query() is called to show the title of the ringtone in Android's settings.
android.media.RingtoneManager.setActualDefaultRingtoneUri(
mContext,
android.media.RingtoneManager.TYPE_RINGTONE,
MY_CONTENT_PROVIDER_URI);
Is this an android limitation?
My URI is "content://Package.ProviderName"
来源:https://stackoverflow.com/questions/27866201/cant-play-a-ringtone-from-a-contentprovider