没有启动的活动发现,尽管的manifest.xml正在申报发现、manifest、xml

2023-09-12 05:04:43 作者:樱花尸.

在我的应用我在manifest.xml文件中定义这样的主要活动:

In my app I have the main activity defined in the manifest.xml file like this:

<activity
            android:name=".MainActivity"
            android:label="@string/guide_activity" >
            <intent-filter>
                <category android:name="android.intent.category.LAUNCHER" />
                <action android:name="android.intent.action.MAIN" />

                <action android:name="android.intent.action.SEARCH" />
            </intent-filter>
            <meta-data android:name="android.app.searchable"
                   android:resource="@xml/searchable"/>
        </activity>

当我从Eclipse运行连接到一个真实的设备或仿真我收到在控制台以下消息的项目: 否发射活动中

when I run the project from eclipse connected to a real device or an emulator I receive the following message in the console: No Launcher activity found

什么都可以这样做的原因是什么?

what can be the reason of this ?

推荐答案

拆分意图过滤成两个独立的人。如果你混淆这个样子,Android将无法确定这两个中的一个发射滤波器。

Split the intent-filter into two seperate ones. If you mix them like this, android won't determine that one of the two is the launcher filter.

<activity
    android:name=".MainActivity"
    android:label="@string/guide_activity" >

        <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>

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