문제

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>

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top