AppIconNameChanger

repository·master·Indexed 20 days ago

https://github.com/myinnos/appiconnamechanger

An Android library that enables developers to programmatically change the application's launcher icon and display name by switching between different activity aliases defined in the AndroidManifest.xml.

Tokens
1.5K
Snippets
3
Records
3
Agent score
20%

What's inside AppIconNameChanger

  1. Configure activity-alias in AndroidManifest.xml

    master

    The library works by switching between different <activity-alias> components defined in your AndroidManifest.xml. Each alias represents a different icon and app name combination.

    To implement this:

    1. Define your main activity.
    2. Define multiple <activity-alias> entries.
    3. Each alias must have a unique android:name (used as the identifier in code), an android:icon, an android:label, and a android:targetActivity pointing to your main activity.
    4. Ensure the alias you want to be the default has android:enabled="true" and includes the MAIN action and LAUNCHER category in its <intent-filter>.
    <application
             .........
            
           <!-- main activity-->
           <activity android:name=".MainActivity" />
    
            <!-- setting activity-alias names-->
            <activity-alias
                android:name="in.myinnos.changeappiconandname.MainActivitySettings"
                android:enabled="true"  //enabled by default launcher
                android:icon="@drawable/ic_settings"  //app icon
                android:label="@string/app_settings"  //app label/name
                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="in.myinnos.changeappiconandname.MainActivityCamera"
                android:enabled="false"
                android:icon="@drawable/ic_camera"  //app icon
                android:label="@string/app_camera" //app label/name
                android:targetActivity=".MainActivity">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity-alias>
    
            .........
    
    </application>
  2. Install AppIconNameChanger via JitPack

    master

    To use this library, add the JitPack repository to your project-level build.gradle file, and then add the dependency to your app-level or module-level build.gradle file.

    Warning: Do not add the dependency to both the app and a module gradle file simultaneously to avoid conflicts.

    // In build.gradle (Project)
    allprojects {
    	repositories {
    	...
    	maven { url "https://jitpack.io" }
    	}
    }
    
    // In build.gradle (App or Module)
    dependencies {
    	compile 'com.github.myinnos:AppIconNameChanger:1.0.7'
    }
  3. Change App Icon and Name using AppIconNameChanger.Builder

    master

    Use the AppIconNameChanger.Builder to programmatically switch the active launcher icon and name.

    Parameters:

    • activeName (String): The unique android:name of the <activity-alias> you want to enable.
    • disableNames (List<String>): A list of the unique android:name values for the aliases you want to disable.
    • packageName (String): The application's package name (e.g., BuildConfig.APPLICATION_ID).

    Important Note: After calling .setNow(), it may take up to 10 seconds for the Android launcher to refresh and show the new icon/name.

    // Active alias name
    String activeName = "in.myinnos.changeappiconandname.MainActivitySettings";
    
    // Disable alias names
    List<String> disableNames = new ArrayList<String>();
    disableNames.add("in.myinnos.changeappiconandname.MainActivityCamera");
    disableNames.add("in.myinnos.changeappiconandname.MainActivityMessage");
    
    // Initiate App Icon Name Changer
    new AppIconNameChanger.Builder(MainActivity.this)
                    .activeName(activeName) // String
                    .disableNames(disableNames) // List<String>
                    .packageName(BuildConfig.APPLICATION_ID)
                    .build()
                    .setNow();