3

I am having this problem. I created a new xml layout (splash screen) and in manifest set it as Launcher category. I did this before tons of time but it never happened before.

When MainActivity is LAUNCHER categpry and I run Spalsh Activity via intent it works. Doing opposite I get error No launcher activity found.

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".SecondActivity"
        android:label="Second Activity" >
        <intent-filter>
            <action android:name="net.learn2develop.SECONDACTIVITY" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".MainActivity"
        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>

No problem in this one, but if I modify it to

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".SecondActivity"
        android:label="Second Activity" >
        <intent-filter>
            <action android:name="net.learn2develop.SECONDACTIVITY" />

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

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

I get error.

Kartik Sharma
  • 723
  • 8
  • 19
  • Add `` to MainActivity – Pankaj Kumar Jul 12 '13 at 08:07
  • If you are using eclipse, you can create a new activity using the wizard. There's a step, where you put the name of the activity and the name of the layout file. Here you can enable the check box "Launcher Activity", and eclipse modify rightly your manifest file. – optimusfrenk Jul 12 '13 at 09:07

2 Answers2

1

try this:

<application

    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".SecondActivity"
        android:label="Second Activity" >
    </activity>
 </application>
Volodymyr Yatsykiv
  • 3,181
  • 1
  • 24
  • 28
1

try with following

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".SecondActivity"
        android:label="Second Activity" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />            
        </intent-filter>
    </activity>
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="net.learn2develop.SECONDACTIVITY" />  <!--(or android.intent.action.VIEW) -->
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
</application>
A.Ruppin
  • 161
  • 6
  • Guys what I did now made both the category as LAUNCHER. Instead of giving error, it simply launched MainActivity.. – Kartik Sharma Jul 12 '13 at 10:03
  • 1
    Did you try with above suggestion? Please refer link http://stackoverflow.com/questions/6288744/android-action-main-and-category-launcher-function for further understanding. – A.Ruppin Jul 12 '13 at 10:20
  • 1
    MAIN action is the main entry point of the application. LAUNCHER category says that entry point should be listed in the application launcher. Note that in your Modified XML, Mention your "SecondActivity" action as MAIN and mark "MainActivity" action as ACTION_DEFAULT or "net.learn2develop.SECONDACTIVITY" for proper functioning. – A.Ruppin Jul 12 '13 at 10:34
  • Thanks.. Now I understand that MAIN action is the main entry point..I thought that LAUNCHER category meant that respective activity must launch. – Kartik Sharma Jul 12 '13 at 12:46