10

I would like my main activity to be searchable also but when I change the manifest.xml to

 <intent-filter>
       <action android:name="android.intent.action.MAIN" />
       <category android:name="android.intent.category.LAUNCHER" />
       <!-- declare the default searchable Activity for the whole app -->
       <action android:name="android.intent.action.SEARCH" />            
 </intent-filter>

it cant find the main activity and the application doesn't run. any idea? is it not best practice to use the same activity as searchable also? Thanks, Alisa

einverne
  • 6,454
  • 6
  • 45
  • 91
Alisa
  • 101
  • 1
  • 4

2 Answers2

19

You need to add a new intent-filter with the action.SEARCH

<activity
    android:name=".activities.YourActivity">
    <intent-filter>
                <category android:name="android.intent.category.LAUNCHER" />
                <action android:name="android.intent.action.MAIN" />
    </intent-filter>
     <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
    </intent-filter>
</activity>
Maragues
  • 37,861
  • 14
  • 95
  • 96
-2

You need add new action in manifest file and link to search metadata, smth like that:

<intent-filter>
  <action android:name="android.intent.action.SEARCH"/>
  <action android:name="android.intent.action.MAIN"/>
  <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="android.app.searchable"
           android:resource="@xml/searchable"/>
HighFlyer
  • 1,615
  • 2
  • 15
  • 22
  • 1
    Take care with this solution: Your activity won't launch automatically. I did like you before, but Maragues answer saved me and give no issue – Waza_Be Jan 09 '12 at 08:30