Android选择外部铃声后,直接选中

 

 1.Settings-》Sound-》Phone ringtone-》Add ringtone
 2.选择手机/SD卡中的音频文件添加到通知铃声列表 
 3.刚添加到铃声列表中的音频文件不会默认被选中,期望被选中  

[SOLUTION]

  

 RingtonePickerActivity.java (vendor\mediatek\proprietary\packages\providers\mediaprovider\src\com\android\providers\media) 
1,private void requeryForAdapter() {
       // Refresh and set a new cursor, closing the old one.
        initRingtoneManager();
        mAdapter.changeCursor(mCursor);


        // Update checked item location.
        int checkedPosition = POS_UNKNOWN;
        for (int i = 0; i < mAdapter.getCount(); i++) {
            if (mAdapter.getItemId(i) == mCheckedItemId) {
                checkedPosition = getListPosition(i);
                break;
            }
        }
        if (mHasSilentItem && checkedPosition == POS_UNKNOWN) {
            checkedPosition = mSilentPos;
        }
     //   setCheckedItem(checkedPosition);
        
        setCheckedItem(getListPosition(mRingtoneManager.getRingtonePosition(mExistingUri)));
        setupAlert();
    }

2,
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);   
     if (requestCode == ADD_FILE_REQUEST_CODE && resultCode == RESULT_OK) {
            // Add the custom ringtone in a separate thread
            final AsyncTask installTask = new AsyncTask() {
                @Override
                protected Uri doInBackground(Uri... params) {
                    try {
Log.d(TAG,"lll onActivityResult doInBackground");
//changed begin
Uri ringtoneUriBySet=mRingtoneManager.addCustomExternalRingtone(params[0], mType);
if(ringtoneUriBySet!=null){
mExistingUri=ringtoneUriBySet;
}
    return ringtoneUriBySet;
//changed end
                    } catch (IOException | IllegalArgumentException e) {
                        Log.e(TAG, "Unable to add new ringtone", e);
                    }
                    return null;

你可能感兴趣的:(android)