Archive

Archive for June, 2012

Create application with multiple entry-point activities

June 4, 2012 2 comments

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

Categories: Home Tags: , ,