Can't play a ringtone from a ContentProvider

岁酱吖の 提交于 2019-12-08 04:18:06

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!