Tag Archives: The activity must be exported or contain an intentfilter

[Solved] The activity must be exported or contain an intent-filter

The following error occurred while testing an activity:

(1) This is generally because this activity is not launcher activity, nor is it set to Android: exported = "true"

*The activity as the startup page in Android must be set to intent filter or exported in mainfest

Solution: you can set Android: exported = "true" on the activity configuration in androidmanifest.xml, or set intent filter

As follows:

        <!--    activity Set exported as true    -->
        <activity android:name=".activity.POStockInActivity" android:exported="true"/>

        <!--    activity set intent-filter    -->
        <activity android:name=".activity.LoginActivity" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

(2) In another case, after modifying launcher activity, run it directly with the shortcut key Shift + F10, which will continue to run with the previous activity

Solution: do not use shortcut keys to start. Right-click the newly set activity and click ‘run xxxactivity’ to run it

*The following figure shows how to modify the launcher activity. You can see that after modifying the launcher activity, you will be warned. You need to set this activity to exported or set intent filter: