androidandroid-manifestandroid-launcher

How to remove second launcher of the app (not default) instead of becoming a duplicate default launcher on new app update?


Currently my app has two launcher icons on fresh install:

    <activity
        android:name="...MainActivity"
        android:exported="true" 
        ...>
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

        <meta-data
            android:name="android.app.shortcuts"
            android:resource="@xml/shortcuts" />
    </activity>

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

The second one is shortcut to start recording (audio or video) without launching the app (invisible/transparent activity which finishes automatically right away after starting a foreground service for recording).

I decided to remove the second launcher in the new update of the app, keep only one (default one to start main screen of the app).

I tried to test it myself on my devices before updating the app on Google Play, I removed the second activity from manifest and installed the app but the second launcher was still on home screen but it became just like default launcher (the same icon and the same activity starts).

How can I fix it?

My users will have two the same launchers in this case after update.

Why it can't be just removed? What's wrong with Android?

Tested on Samsung/Pixel devices, Android 11+


Solution

  • There are tens of thousands of Android device models. They will have hundreds of different launcher implementations pre-installed, and there are many more launcher implementations available in the Play Store, F-Droid, and elsewhere.

    Not all of these will react to an app update that changes the mix of launchable activities. They could, but that requires code in the launcher app, and not all launcher apps will have that code.

    The most typical way of forcing a launcher to reload is to reboot the device, so whatever in-RAM cache the launcher uses needs to be recreated.

    So basically there is no solution until users will try to reboot the device or reinstall the app?

    Some launchers will behave as you expect, reacting in real time to the updated app's manifest. Others will not. The closest thing we have to a universal solution is a reboot (or an uninstall/reinstall, as you suggest, but that is more work and more invasive).