http://blog.csdn.net/jkkjklmn/article/details/6959686
DefaultRingtonePreference单击后出现的是一个AlertDialog,但是在DefaultRingtonePreference没看见任何构造Dialog的信息,显然构建在父类RingtonePreference中,
在RingtonePreference.java中:- protected void onClick() { //注意这对DefaultRingtonePreference单机事件左的处理有跳转
- // Launch the ringtone picker
- Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
- onPrepareRingtonePickerIntent(intent);
- getPreferenceManager().getActivity().startActivityForResult(intent, mRequestCode);
- }
这里的startActivityForResult就跳转到了RingtonePickerActivity.java文件里面,
在RingtonePickerActivity.java中:- public void onClick(DialogInterface dialog, int which) {
- Log.i(TAG,"------onClick----");
- boolean positiveResult = which == DialogInterface.BUTTON_POSITIVE;
- // Stop playing the previous ringtone
- mRingtoneManager.stopPreviousRingtone();
- if (positiveResult) {
- Intent resultIntent = new Intent();
- Uri uri = null;
- if (mClickedPos == mDefaultRingtonePos) {
- // Set it to the default Uri that they originally gave us
- uri = mUriForDefaultItem;
- } else if (mClickedPos == mSilentPos) {
- // A null Uri is for the 'Silent' item
- uri = null;
- } else {
- uri = mRingtoneManager.getRingtoneUri(getRingtoneManagerPosition(mClickedPos));
- }
- resultIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI, uri);
- setResult(RESULT_OK, resultIntent);
- } else {
- setResult(RESULT_CANCELED);
- }
会把当前选中的那个铃声的URI返回给在RingtonePreference.java,