title: Android: forward search queries to one single activity that handles search
body: <p>I have an activity handling search (<strong>ACTIVITY_1</strong>), which works perfectly when I use the search (via SEARCH button on the phone) within/from this activity.</p>
  
  <p>However, when I use search from another activity (<strong>ACTIVITY_2..x</strong>) by implementing <code>onNewIntent</code> and forward the query string to my Search_Activity.class (<strong>ACTIVITY_1</strong>)</p>
  
  <pre><code>@Override
  protected void onNewIntent(Intent intent) {
      Log.i(TAG, "onNewIntent()");
  
      if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
          Log.i(TAG, "===== Intent: ACTION_SEARCH =====");
          Intent myIntent = new Intent(getBaseContext(), Search_Activity.class);
          myIntent.setAction(Intent.ACTION_SEARCH);
          myIntent.putExtra(SearchManager.QUERY, intent.getStringExtra(SearchManager.QUERY));
          startActivity(myIntent);
      }
  
  }
  </code></pre>
  
  <p>it always pauses <strong>ACTIVITY_2</strong> first and then goes to onCreate() of <strong>ACTIVITY_2</strong>.</p>
  
  <ul>
  <li>Why does it recreate my <strong>ACTIVITY_2</strong> when it is already there and doesn't go to onNewIntent directly?</li>
  <li>Is there another way I can forward search queries directly to <strong>ACTIVITY_1</strong>? For example via a setting in the Manifest.xml</li>
  <li>Is it possible to generally forward all search queries automatically to <strong>ACTIVITY_1</strong> without even implementing <code>onNewIntent</code> in all the other activities?</li>
  </ul>
  
  <p>Currently I have to put an <code>&lt;intent-filter&gt;</code> in every single activity to "activate" my custom search there and forward the query then to the activity that handles search via the <code>onNewIntent</code> (as shown above).</p>
  
  <pre><code>&lt;activity android:name=".Another_Activity"
      android:theme="@style/MyTheme"&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>