Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I invoke the search dialog using onSearchRequested()
    text
    copied!<p>I'm trying to implement the search dialog and I am unable to display the search from an Activity.</p> <p>I have my main activity defined in my manifest file, this activity shows the user a list of options they have to choose from. One of the options is a Search option.</p> <pre><code> &lt;activity android:name=".MenuListActivity" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre> <p>My Search activity is defined in my manifest file like so. </p> <pre><code>&lt;activity android:name=".SearchActivity" android:launchMode="singleTop" android:label="@string/app_name"&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>Now my problem is when I call the onSearchRequested() from my MenuListActivity nothing happens. </p> <pre><code>public void onItemClick(AdapterView&lt;?&gt; parent, View itemClicked, int position, long id) { String strText = items[position]; if (strText.equalsIgnoreCase(getResources().getString(R.string.menu_item_browse))) { startActivity(new Intent(MenuListActivity.this, WSMobileActivity.class)); } else if (strText.equalsIgnoreCase(getResources().getString(R.string.menu_item_search))) { // If i call it like this it doesn't work, nothing happens onSearchRequested(); } else if (strText.equalsIgnoreCase(getResources().getString(R.string.menu_item_locator))) { startActivity(new Intent(MenuListActivity.this, StoreLocatorActivity.class)); } } </code></pre> <p>Please help, how do I invoke the search request from my MenuActivity? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload