title: Search Dialog is not called onSearchRequested()
body: <p>I have been stuck on this for a little while now. I have looked at other answers on <code>SO</code> but they did not help me solve my problem. </p>
  
  <p>My problem is that the search dialog is not invoked by <code>onSearchRequested()</code>. I am not able to figure out what is going on with my search...</p>
  
  <p>The relevant code is as below...</p>
  
  <p><strong>Manifest</strong></p>
  
  <pre><code>&lt;activity
      android:name=".SearchableActivity"
      android:label="@string/app_name"
      android:launchMode="singleTop" &gt;
      &lt;intent-filter&gt;
          &lt;action android:name="android.intent.action.SEARCH" /&gt;
      &lt;/intent-filter&gt;
      &lt;meta-data
          android:name="android.app.searchable"
          android:resource="@xml/searchable" /&gt;
  &lt;/activity&gt;
  </code></pre>
  
  <p><strong>/res/xml/searchable.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;searchable xmlns:android="http://schemas.android.com/apk/res/android"
      android:label="@string/app_name"
      android:hint="@string/search_hint" &gt;
  
  &lt;/searchable&gt;
  </code></pre>
  
  <p>I have the string resources defined in <code>strings.xml</code>.</p>
  
  <p><strong>SearchableActivity class</strong></p>
  
  <pre><code>public class SearchableActivity extends ListActivity {
  
      public void onCreate(Bundle savedInstanceState) { 
            super.onCreate(savedInstanceState); 
            Log.d("SEARCH", "HERE");
            handleIntent(getIntent()); 
         } 
  
         public void onNewIntent(Intent intent) { 
            setIntent(intent); 
            handleIntent(intent); 
         } 
  
         public void onListItemClick(ListView l, View v, int position, long id) { 
            // call the appropriate detail activity
         } 
  
         private void handleIntent(Intent intent) { 
            if (Intent.ACTION_SEARCH.equals(intent.getAction())) { 
               String query = intent.getStringExtra(SearchManager.QUERY); 
               doSearch(query); 
            } 
         }    
  
         private void doSearch(String queryStr) { 
             Toast.makeText(getApplicationContext(), queryStr, Toast.LENGTH_LONG).show();
         } 
  
  }
  </code></pre>
  
  <p>The piece of code in the activity that is invoking the search...</p>
  
  <pre><code>@Override
  public boolean onOptionsItemSelected(MenuItem item) {
      if(item.getTitle().equals("Search")) {
          Toast.makeText(getApplicationContext(), "Search = "+onSearchRequested(), Toast.LENGTH_LONG).show();
          return onSearchRequested();
      } else {
          return false;
      }
  }
  </code></pre>
  
  <p><code>onSearchRequested()</code> is returning <code>true</code>. But the <code>SearchableActivity</code> is not called. Any help is appreciated.</p>
  
  <p>Thank you very much.</p>
  
  <hr>
  
  <p><strong>UPDATED</strong></p>
  
  <p>Never mind! I figured it out!</p>
  
  <p>The solution was to move the <code>meta-data</code> outside the <code>activity</code> tag and inside the <code>application</code> tag. Have added below as an answer for those who run into this problem.</p>
  
  <p>Thanks.</p>