Note that there are some explanatory texts on larger screens.

plurals
  1. POGet result from SearchManager activity to Main Activity in android
    text
    copied!<p>Use Case: Activity A is main activity. Whereas Activity B is SearcActivity (SearchManager). Activity B is ListActivity, so whatever result comes, result is displayed in the list. Once user clicks on the list, I want to get that list selected item to be returned to ActivityA.</p> <p>What I did? I could call SearchActivity on button using "onSearchRequested()". In ActivityB, I am displaying searchresult via "setListAdapter(adapter)". Using "onListItemClick", I can get what option in list was selected by user. </p> <p>Now I tried sending result back to ActivityA by following code</p> <pre><code>Intent intent = new Intent(); Bundle bundle = new Bundle(); bundle.putString("item", l.getItemAtPosition(position).toString()); intent.putExtras(bundle); setResult(RESULT_OK, getIntent() ); finish(); </code></pre> <p>And in ActivityA, I tried reading the result in "onActivityResult".</p> <pre><code>Bundle bundle = data.getExtras(); String strItem = bundle.getString("item"); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Item Selected"); alertDialog.setMessage("Item = " + strItem); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alertDialog.show(); </code></pre> <p>Problem: I noticed that, once Activity A is resumed, "onActivityResult" is not called at all. Hence I am not seeing any dialog. Plus I can't verify whether SearchActivity actually sends anything to ActivityA.</p> <p>So friends, how can I capture the data sent by ActivityB.</p>
 

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