Home > Home > Create application with multiple entry-point activities

Create application with multiple entry-point activities


A great stuff I’ve got today is that “An application can have many different entry-point activities.”

Here the sample, I create a project with four Activities: First Act, Second Act, Third Act, Four Act

Multiple entry-point Activites for one application

Multiple entry-point Activites for one application

The trick behind this stuff is to register your desired activities on AndroidManifest.xml w/ <intent-filter> is MAIN.

The sample for my sample case it should be like this:

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="First Act"
            android:name=".FirstAct"
            android:icon="@drawable/ic_first_act"
            android:taskAffinity=".FirstAct"
            >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:label="Second Act"
            android:name=".SecondAct"
            android:icon="@drawable/ic_second_act"
            android:taskAffinity=".SecondAct"
            >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:label="Third Act"
            android:name=".ThirdAct"
            android:icon="@drawable/ic_third_act"
            android:taskAffinity=".ThirdAct"
            >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

       <activity
            android:label="Four Act"
            android:name=".FourAct"
            android:icon="@drawable/ic_four_act"
            android:taskAffinity=".FourAct"
            >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

There are some applications done this before. As I remember the app: “Facebook for Android” in version 1.9.0 (release on 19/Apr/2012) containing three activites registering to MAIN/LAUNCHER.

Cheers,

Pete Houston

Advertisements
Categories: Home Tags: , ,
  1. September 10, 2016 at 8:39 am

    It did not work for me. Only one Activity was constantly launched.

  2. rajasehkar
    July 23, 2014 at 5:53 pm

    Hi,

    With out android:taskAffinity also it will create 4 launcher icons then we have to use android:taskAffinity can you please explain

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: