Вот мое решение. Я расширил ListPreference своим собственным классом. Когда диалоговое окно закрыто, я вызываю программу выбора для списка аудио. Когда выбор завершается, вызывается пользовательский родительский PreferenceActivity.
Соответствующие биты кода:
public class AlertBehaviorPreference extends ListPreference {
...
public void onDialogClosed(boolean positiveResult)
{
super.onDialogClosed(positiveResult);
if(positiveResult)
{
String s = this.getValue();
if(s != null && s.equals(SONG_ALARM_ACTION)) // play song
{
// Get the parent activity.
// This activity will be notified when the audio has been selected
PreferenceActivity pActivity = (PreferenceActivity)this.getContext();
// Select a recording
Intent i = new Intent(pActivity, pActivity.getClass());
i.setAction(Intent.ACTION_GET_CONTENT);
i.setType("audio/*");
pActivity.startActivityForResult(Intent.createChooser(i, "Select song"), 1);
Log.d(TAG, "Started audio activity chooser");
}
public class MyPreferenceActivity extends PreferenceActivity {
...
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Call back into the preference to save data
// Where the result can be validated and settings can be
// be reset if the user cancelled the request.
((AlertBehaviorPreference)(findPreference("alertBehaviorPreference"))).onSongActivitySelectionComplete(data);
}