2

OK, here we go:

I have a search interface/ dialog (the type that gets created by the system) This calls FilesList, an activity that when called without a search intent will show all of a users items (This works fine when it is called from the main activity)

The query from the search filters these results fine, but when the user selects one of these results it will return to the previous activity, whereas I want it to always return to the main activity, passing the id of the selected item (Which I can get fine)

Also, in whichever activity I call the search from, onActivityResult is not called (Because the search intent isn't for a result?)

Basically, always return to main activity after search, returning an item selected in FilesList

EDIT:

To select an item the user clicks a listview and calls this method:

protected void onListItemClick(ListView l, View v, int position, long id) {
    Log.d("onclick ID", ((Note)data.get(position)).ID);
    Note array=(Note)data.get(position);
    intent.putExtra("id", array.ID);
    intent.putExtra("tag", currentTag);
    setResult(RESULT_OK, intent);
    finish();
}

And the search is launched like this: http://developer.android.com/guide/topics/search/search-dialog.html

Will Richardson
  • 7,780
  • 7
  • 42
  • 56
  • Can you give some more detail as to how the Activity that gets the results and displays them as a list? Is it something you have written and have full control of? If you want a result, you should start the activity with `startActivityForResult` and when your child activity finishes, it should call `setResult`. – BDFun Jun 10 '12 at 09:04

1 Answers1

0

Ok, Instead of trying to return to that activity, I simply make the search point to my main activity and from there I get the query, sort the results and return it to my main activity to be opened.

Basically re-arranged the program flow, this post kinda helped: Android: Return search query to current activity

Community
  • 1
  • 1
Will Richardson
  • 7,780
  • 7
  • 42
  • 56