lor
lor

Reputation: 137

Android - How to change entry point of App without removing shortcuts?

So, in a previous version of my Application, I had an entry point named MainActivity

    <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>

This version, I have a new entry point for my application, which then re-directs to MainActivity or another screen programmatically. Here are the two activities:

    <activity
        android:name=".NewEntryPoint"
        android:label="@string/title_activity_second" >
        <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>
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

I removed the action.MAIN from main activity and set it to my NewEntryPoint. However, any users that had the application as a shortcut on their homescreen will lose the shortcut. Keeping the Launcher category in MainActivity didn't help either.

Is there a way to change entry point of my App without removing shortcuts?

Thanks!

Upvotes: 2

Views: 2569

Answers (1)

Kevin Coppock
Kevin Coppock

Reputation: 134684

I believe you could use activity-alias for this, but I would question whether or not it's worth the future maintenance just to avoid users having to add a shortcut to your app again. Something like this:

<activity-alias
    android:name=".MainActivity"
    android:targetActivity=".NewEntryPoint">

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

</activity-alias>

Upvotes: 1

Related Questions