簡體   English   中英

不允許使用意圖過濾器?

[英]intent-filter is not allowed?

我收到"Element intent-filter is not allowed here"錯誤。 說明是簡單地將意圖過濾器從WeatherActivity剪切並粘貼到MainMenuActivity ,因為WeatherActivity是首先創建的,但是當我這樣做時它不喜歡它。 我究竟做錯了什么?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.introandroidapp">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.IntroAndroidApp">

        <activity
            android:name=".MyDrawing"
            android:exported="false" />
        <activity
            android:name=".MainMenuActivity"
            android:exported="false" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

        <activity
            android:name=".WeatherActivity"
            android:exported="true">

        </activity>
    </application>

</manifest>

<intent-filter>應該在activity標簽內。 如果要將MainMenuActivity標記為 main,請嘗試以下操作:

 <activity
        android:name=".MainMenuActivity"
        android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

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

不要忘記main活動應該有exported="true"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM