0

My main activity needs to invoke a search and display search results. The search dialog does not appear when onSearchRequested() is called.

I have found similar questions and followed every detail (I think) but apparently I have something else wrong. Here are snips of my implementation.

Parts of AndroidManifest.xml

<application
    android:label="@string/AppName"     
    android:launchMode="singleTop"
    ... >

    <meta-data 
      android:name="android.app.default_searchable"
      android:value=".main.MainActivity" />

    <activity
      android:name=".main.MainActivity"
      android:launchMode="singleTop" 
      ... >

      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>

      <intent-filter>
        <action android:name="android.intent.action.SEARCH" />
      </intent-filter>

      <meta-data
        android:name="android.app.searchable"
        android:resource="@xml/deep_search" />

    </activity>
    ...
</application>

deep_search.xml

<?xml version="1.0" encoding="utf-8"?>
<Searchable
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:label="@string/AppName"
  android:hint="@string/search_deep_hint" >
</Searchable>

Parts of MainActivity:

public class MainActivity extends Activity implements ...
{
  @Override
  protected void onNewIntent (Intent intent)
  {
    setIntent(intent);
    if (Intent.ACTION_SEARCH.equals(intent.getAction()))
    {
      String query = intent.getStringExtra (SearchManager.QUERY);
      // Do work using string
    }
  }

  @Override
  public boolean onOptionsItemSelected (MenuItem item) 
  { 
    int selectedId = item.getItemId();
    switch (selectedId)
    { 
      case ...:

      case R.id.menu_search_deep:
          boolean launched = onSearchRequested();
          logI ("home page deep searched launched: " + launched); // log shows we got here
        }
        return true; 
    }

  ...
}
Peri Hartman
  • 19,314
  • 18
  • 55
  • 101
  • take a look here: http://stackoverflow.com/questions/27671954/android-prevent-text-truncation-in-searchview-suggestions – user2511882 Jun 02 '15 at 16:00
  • That's a huge post with a farily extensive answer discussing things which don't seem relevant to my issue. Can you hint as to what I'm looking for? Thanks. – Peri Hartman Jun 02 '15 at 16:28

0 Answers0