Search code examples
androidsearchsearchviewstart-activity

Android SearchView: startActivity() gets called twice


The architecture is the following:

1) MainActionBarActivity - base class, which implements the ActionBar behavior, i.e. overriding onCreateOptionsMenu(), onOptionsItemSelected(), onSearchRequested() and startActivity()
2) HomeActivity extends MainActionBarActivity
3) SearchableActivity extends MainActionBarActivity

For some reason, when typing in the search box in HomeActivity and hit Enter, startActivity() gets called twice and therefore 2 intents arrive at SearchableActivity (debug messages in LogCat)

Could you give me some directions where the problem might be?


Solution

  • As SearchableActivity was set with launchMode="singleTop" I had to override onNewIntent().
    The problem was solvled by removing super.onNewIntent().