0

I am making an android application that needs to display a simple quick search, but to do this i need to change the:

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

To:

<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />

But once I do, the application doesn't find a launcher activity, how can i fix this? This is the code that i am using:


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mysoftwaremobileapps.School"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="3" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:label="@string/app_name"
        android:name=".SchoolActivity" >
        <intent-filter >
            <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" />
    </activity>
    <activity android:name=".GoogleActivity" android:label="@string/app_name"></activity>
    <activity android:name=".WikipediaActivity" android:label="@string/app_name"></activity>
    <activity android:name=".ProjectsActivity" android:label="@string/app_name"></activity>
    <activity android:name=".NotesActivity" android:label="@string/app_name"></activity>
    <activity android:name=".SearchFunction" android:label="@string/app_name">
        <intent-filter android:label="ACTION_SEARCH"></intent-filter>
    </activity>
</application>

animuson
  • 53,861
  • 28
  • 137
  • 147
user1183066
  • 115
  • 2
  • 6
  • 20

1 Answers1

0

There is no reason for a LAUNCHER to exist in a searchable activity.

The point of a searchable activity is that after a search is triggered by the user, your activity then receives the search query, searches your datastore, and finally presents the results.

Now if you wanted a separate activity that does something related to your datastore, for example input or import data, then by all means go ahead and create another activity and assign LAUNCHER to that activity. The searchable activity isn't meant to be a LAUNCHER activity.

Marvin Pinto
  • 30,138
  • 7
  • 37
  • 54
  • But if i dont change it, it doesn't happen anything when i press search – user1183066 Feb 08 '12 at 18:41
  • And how do i get the text that the user entered into the search field into a string? – user1183066 Feb 08 '12 at 18:44
  • @user1183066 Is your search activity able to receive, search and present the results (see the examples above)? It will _only_ be able to return results after you get that working. Please go through the examples I linked to and get a basic search application going before expanding into a WebView. – Marvin Pinto Feb 08 '12 at 18:44