I have an activity that handles search requests with the SearchManager and it's working just fine. Let's call this activity MySearchActivity.java. The problem is that within this activity, I have a button that invokes the search request dialog with a call to onSearchRequested().

If MySearchActivity.java is the current task in the activity stack and the user taps the icon within this activity that calls onSearchRequested(), this activity is re-launched on top of itself. So within the activity stack, I have two of the same activities on top of each other.

I don't want to use android:noHistory in the manifest for this activity, and can't find any other suitable flags for what I'd like to accomplish.

I would like that if the user taps the icon in MySearchActivity.java which invokes the call to onSearchRequested(), that the activity not duplicate itself in the stack.

I know I'm probably overlooking something or making this more complicated than it really is....any ideas?

1

There are 1 best solutions below

0
On BEST ANSWER

For the solution you probably have to set launch mode to "singleTop" for activity (e.g android:launchMode="singleTop"). Here is the further explenation @documentation. Good luck!