2
votes

I renamed my MainActivity class to DataActivity and added a new main activity class with IntelliJ IDEA. I changed the AndroidManifest.xml file to the following:

 <application android:label="@string/app_name" android:icon="@drawable/icon">
        <activity android:name=".DataActivity"
                  android:screenOrientation="portrait">
        </activity>
        <activity android:name=".MainActivity" android:screenOrientation="portrait"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
</application>

I uninstalled the app from my phone and deleted the compiler cache. At install, I get the following exception:

Launching application: com.example.DataTest/com.example.DataTest.DataActivity.

DEVICE SHELL COMMAND: am start -n "com.example.DataTest/com.example.DataTest.DataActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.DataTest/.DataActivity } from null (pid=5882, uid=2000) requires null

What else should I do?

2

2 Answers

2
votes

This post helped me where to look. In the comments, zeh claims that the SDK holds a refence to the original activity. I checked the launch configuration, and in my IDEA it has been altered from "Launch default activity" to "Launch activity: DataActivity". It works now okay.

0
votes

Change it to this to include the intent filters with your new main activity:

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

and remove "MainActivity" if it no longer exists. i.e. delete this:

<activity android:name=".MainActivity" android:screenOrientation="portrait"
          android:label="@string/app_name">
</activity>