2

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?

Nestor
  • 8,194
  • 7
  • 77
  • 156

2 Answers2

2

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.

Community
  • 1
  • 1
Nestor
  • 8,194
  • 7
  • 77
  • 156
0

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>
Jim
  • 10,172
  • 1
  • 27
  • 36
  • 1
    You misunderstood me. I want MainActivity to be the main activity that's why I renamed the original to DataActivity. I can't remove it. – Nestor Jan 18 '14 at 21:20
  • You are trying to launch the app from "DataActivity" in your shell command line. You cannot launch into any activity but the one that has the action "MAIN" – Jim Jan 18 '14 at 21:46