Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to startActivityForResult() in a dialog to receive result in fragment.onActivityResult
    primarykey
    data
    text
    <p>I have a Fragment in which I call <code>this.startActivityForResult()</code>, the result arrives in this Fragment's <code>onActivityResult()</code> method and everthing works fine. </p> <p>When I open a new <code>Dialog</code> in the same <code>Fragment</code>, how do I call <code>startActivityForResult()</code> in the Dialog to receive the result in the Fragment's <code>onActivityResult()</code> method as well?</p> <pre><code>getOwnerActivity().startActivityForResult(intent, NOTIFY_CODE); // doesn't work </code></pre> <p>Tried to send the Fragment's (<code>this</code>) to the dialog but I can't figure that out either.</p> <p>- ..any help is highly appreciated!</p> <p>EDIT: Code for opening the dialog</p> <pre><code> btnNotify.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { NotificationDialog ndialog = new NotificationDialog(v.getContext()); ndialog.requestWindowFeature(Window.FEATURE_NO_TITLE); ndialog.setDialogResult(new NotificationDialog.OnMyDialogResult() { @Override public void finish(int dur) { notifyDuration = dur; } }); ndialog.show(); } </code></pre> <p>// -- in the Dialog I want to call this</p> <pre><code>public void openNotifySel() { Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getOwnerActivity().getResources().getString(R.string.label_dialog_notify)); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION); ??????????????.startActivityForResult(intent, NOTIFY_CODE); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload