Dynamic Launcher Icon and Name for Android App 2024

Here is the simple way to change your android apps Dynamic Launcher Icon and Name for Android App. If you want multiple launcher icons and Application names these Android tutorials for you you can see some simple steps to make your App Dynamic Launcher Icon and Name for Android.

Let’s Start to Create an Android Project and make Dynamic Launcher Icon and Name for Android App.

Step 1.  Create a 3  Java Class with the Name of  OneLauncher, TwoLauncher, ThreeLauncher.

In this step, you can create a 3 java class with the name reference according to you.  After that Add activity-alias in your AndroidManifest.xml. These all 3 class add-in Manifest with the activity-alias teg. Dynamic Launcher Icon and Name for Android App.

 

Step 2. Add activity-alias in your AndroidManifest.xml

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <activity android:name=".MainActivity"></activity>


    <activity-alias
        android:name="OneLauncherAlias"
        android:enabled="true"
        android:icon="@mipmap/ic_launcher"
        android:label="One"
        android:targetActivity=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity-alias>

    <activity-alias
        android:name="TwoLauncherAlias"
        android:enabled="false"
        android:label="Two"
        android:icon="@mipmap/ic_launcher1"
        android:targetActivity=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity-alias>

    <activity-alias
        android:name="ThreeLauncherAlias"
        android:enabled="false"
        android:label="Three"
        android:icon="@mipmap/ic_launcher2"
        android:targetActivity=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity-alias>
</application>

 

Step 3. Enable and disable the activity-alias based on your requirement

Enable and disable the activity-alias based on your requirement. In my example, On click of the one layout, I am enabling the activity-alias OneLauncherAlias and disabling the rest.

Like You have 3 Button Iocns1,  Icons2, Icons3,  When clicking on Icons1 to set Launcher One Icon and Name, and then to click on Icons2 Button set Launcher Two Icons Name.

In Your Main Activity, XML file Add 3-4 Buttons 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
    tools:context=".MainActivity">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:id="@+id/Button"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button1"/>

        <Button
            android:id="@+id/Button1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button2"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:id="@+id/Button2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button3"/>

        <Button
            android:id="@+id/Button3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button4"/>
    </LinearLayout>
</LinearLayout>

Dynamic Launcher Icon and Name for Android App

Step 4 Main activity Java Class On button click change icons and name 

public class MainActivity extends AppCompatActivity {

    Button Button1,Button2,Button3,Button4;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button1=findViewById(R.id.Button);
        Button2=findViewById(R.id.Button1);
        Button3=findViewById(R.id.Button2);
        Button4=findViewById(R.id.Button3);

        Button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PackageManager pm = getPackageManager();
                pm.setComponentEnabledSetting(new ComponentName(MainActivity.this, OneLauncher.class), PackageManager.COMPONENT_ENABLED_STATE_ENABLED,PackageManager.DONT_KILL_APP);
                pm.setComponentEnabledSetting(new ComponentName(MainActivity.this, TwoLauncher.class), PackageManager.COMPONENT_ENABLED_STATE_DISABLED,PackageManager.DONT_KILL_APP);
                pm.setComponentEnabledSetting(new ComponentName(MainActivity.this, ThreeLauncher.class), PackageManager.COMPONENT_ENABLED_STATE_DISABLED,PackageManager.DONT_KILL_APP);

                Toast.makeText(MainActivity.this, "Launcher one has been applied successfully",Toast.LENGTH_SHORT).show();

            }
        });

        Button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PackageManager pm = getPackageManager();
                pm.setComponentEnabledSetting(new ComponentName(MainActivity.this, OneLauncher.class), PackageManager.COMPONENT_ENABLED_STATE_DISABLED,PackageManager.DONT_KILL_APP);
                pm.setComponentEnabledSetting(new ComponentName(MainActivity.this, TwoLauncher.class), PackageManager.COMPONENT_ENABLED_STATE_ENABLED,PackageManager.DONT_KILL_APP);
                pm.setComponentEnabledSetting(new ComponentName(MainActivity.this, ThreeLauncher.class), PackageManager.COMPONENT_ENABLED_STATE_DISABLED,PackageManager.DONT_KILL_APP);

                Toast.makeText(MainActivity.this, "Launcher one has been applied successfully",Toast.LENGTH_SHORT).show();

            }
        });

        Button3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PackageManager pm = getPackageManager();
                pm.setComponentEnabledSetting(new ComponentName(MainActivity.this, OneLauncher.class), PackageManager.COMPONENT_ENABLED_STATE_DISABLED,PackageManager.DONT_KILL_APP);
                pm.setComponentEnabledSetting(new ComponentName(MainActivity.this, TwoLauncher.class), PackageManager.COMPONENT_ENABLED_STATE_DISABLED,PackageManager.DONT_KILL_APP);
                pm.setComponentEnabledSetting(new ComponentName(MainActivity.this, ThreeLauncher.class), PackageManager.COMPONENT_ENABLED_STATE_ENABLED,PackageManager.DONT_KILL_APP);

                Toast.makeText(MainActivity.this, "Launcher one has been applied successfully",Toast.LENGTH_SHORT).show();

            }
        });

        Button4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });

    }
}


 

Read More Tutorial 

You may also like...