Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error running second Activity: The activity must be exported or contain an intent-filter

I cant seem to launch my application. It gives me an error like this: "Error running second Activity: The activity must be exported or contain an intent-filter".

Is there anything wrong with my manifest?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="sg.edu.rp.g913.mymakeuppouch">


    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>
like image 373
petrichor-vellichor Avatar asked Nov 07 '16 12:11

petrichor-vellichor


3 Answers

Put android:exported="true" in the <activity> tag

<activity android:name=".secondActivity"
    android:exported="true">
like image 181
Ognian Gloushkov Avatar answered Nov 15 '22 10:11

Ognian Gloushkov


You should set the Run>edit configuration to the desired launcher activity and give the intent filter at the manifest to the correct activity

below is the error creating situation

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    </activity>
    <activity android:name=".Page_2">
    </activity>
</application>

Image showing incorrect configuration

correct configuration and code are given below to run Mainactivity as launcher activity

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

corrected configuration window

like image 24
Manoranjan Avatar answered Nov 15 '22 09:11

Manoranjan


  1. Get to your Run menu and select edit configuration.
  2. In the run/debug configuration widows, select your app in the left column (if it is not yet selected).
  3. under launch option: launch, click the side arrow and choose the "specified activity" option.
  4. type in the name of the activity you which to launch your apps with or tab on the side button(...) and select from your activities.
like image 2
Hansel Avatar answered Nov 15 '22 09:11

Hansel