title: How to start search dialog in a new Activity?
body: <p>I need to implement a search function in my Android application. I would like to have the "Search" hardware button <strong>launch a new Activity</strong> with the standard search dialog already displayed. I guess I could do it manually, but maybe there is a way to do this using the standard Search dialog?</p>
  
  <p>Here is what I do:</p>
  
  <p>In the MainActivity I hijack the search button, like this:</p>
  
  <pre><code>    public boolean onKeyDown(int KeyCode, KeyEvent event) {
      if (KeyCode==KeyEvent.KEYCODE_SEARCH &amp;&amp; event.getRepeatCount() == 0){
          Intent i = new Intent(Month.this, SearchActivity.class);
          i.setAction("android.intent.action.SEARCH");
          startActivity(i);           
          return true;
      }
      return super.onKeyDown(KeyCode, event);
  }
  </code></pre>
  
  <p>In the Android Manifest.xml, in the SearchActivity section I have this:</p>
  
  <pre><code>        &lt;activity android:name=".SearchActivity"
                          android:screenOrientation="portrait"
                          android:launchMode="singleTop"
                          android:configChanges="keyboardHidden|orientation"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.SEARCH" /&gt;
              &lt;category android:name="android.intent.category.DEFAULT" /&gt;
          &lt;/intent-filter&gt;
          &lt;meta-data android:name="android.app.searchable"
                android:resource="@xml/searchable"/&gt;
  
      &lt;/activity&gt;
  </code></pre>
  
  <p>And in the MainActivity section:</p>
  
  <pre><code>        &lt;activity android:name=".MainActivity"
                          android:screenOrientation="portrait"
                          android:configChanges="keyboardHidden|orientation"&gt;
                      &lt;meta-data android:name="android.app.default_searchable"
                              android:value=".SearchActivity" /&gt;
  
      &lt;/activity&gt;
  </code></pre>
  
  <p>I assumed, that sending the <em>android.intent.action.SEARCH</em> to the SearchActivity should open the Search Dialog. But it does not.... SearchActivity is displayed, but I have to press Search button again to see the Search dialog. 
  What am I missing?</p>