Subramanyam M
Subramanyam M

Reputation: 325

Android : Android Activity Launch Error

I Have searched for the problem and couldn't find solution for my problem, please help me with this code

<?xml version="1.0" encoding="utf-8"?>
     <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.example.androidpractise"
     android:versionCode="1"
     android:versionName="1.0" >

     <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

     <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.androidpractise.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>
        <activity 
            android:name="com.example.androidpractise.Second"
            android:label="@string/second_app">
            <intent-filter>
                <action android:name="android.intent.action.SECOND"/>

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

 </manifest>

What is wrong with the above code i get

[2014-08-27 10:34:24 - AndroidPractise] No Launcher activity found!
[2014-08-27 10:34:24 - AndroidPractise] The launch will only sync the application package on the device!

Upvotes: 0

Views: 1829

Answers (6)

Mavya Soni
Mavya Soni

Reputation: 11

    <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="com.example.androidpractise.Second"
       android:label="@string/second_app">

                </activity>

Upvotes: 1

Narendra Pal
Narendra Pal

Reputation: 6604

Change to

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

instead of

<action android:name="android.intent.action.SECOND"/>

If you want to launch MainActivity then do this

<activity
        android:name="com.example.androidpractise.Second"
        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="com.example.androidpractise.Second"
        android:label="@string/second_app">
    </activity>

Or if you want to launch Second class then do this...

 <activity
            android:name="com.example.androidpractise.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="com.example.androidpractise.MainActivity"
            android:label="@string/second_app">
        </activity>

The launcher category should always have

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

Upvotes: 0

Ashish Saini
Ashish Saini

Reputation: 2318

Copy this code

   <uses-sdk
    android:minSdkVersion="8"
     android:targetSdkVersion="18" />

     <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
         android:label="@string/app_name"
         android:theme="@style/AppTheme" >
    <activity
    android:name="com.example.androidpractise.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="com.example.androidpractise.Second"
       android:label="@string/second_app">

                </activity>
              </application>

Upvotes: 0

Naveen Tamrakar
Naveen Tamrakar

Reputation: 3339

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
    android:name="com.example.androidpractise.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="com.example.androidpractise.Second"
    android:label="@string/second_app">
    <intent-filter>
        <action android:name="android.intent.action.SECOND"/>

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

Upvotes: 0

Indra Kumar S
Indra Kumar S

Reputation: 2934

Add this to a Launcher activity

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

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

Code for second activity as a launcher would be

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
  <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
    android:name="com.example.androidpractise.MainActivity"
    android:label="@string/app_name" >

</activity>
<activity 
    android:name="com.example.androidpractise.Second"
    android:label="@string/second_app">
    <intent-filter>
       <action android:name="android.intent.action.MAIN" />

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

Upvotes: 0

suitianshi
suitianshi

Reputation: 3340

you should add category_launcher to your main activity, not android.intent.category.DEFAULT. action.main always work with category_launcher

Upvotes: 0

Related Questions