I am trying to add different types of App icons and different App names dynamically based on different places for the same application without update!. Otherwise, I need to provide 3 different builds. I hope I am clear.
Asked
Active
Viewed 1,539 times
3
-
Icon is possible. Reddit app actually supports this. Name, not so sure. However, this question doesn't really fit here as it stands – XtremeBaumer Aug 03 '22 at 06:53
-
Does this answer your question? [How to provide different Android app icons for different gradle buildTypes?](https://stackoverflow.com/questions/22875948/how-to-provide-different-android-app-icons-for-different-gradle-buildtypes) – Amirhosein Aug 03 '22 at 06:55
-
yup and also am looking for change the "app Name" too. – Mahesh Aug 03 '22 at 07:00
1 Answers
1
Go to your AndroidManifest.xml file and add this code
<application
android:theme="@style/Theme.packagename"
android:supportsRtl="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher_first"
android:allowBackup="true">
<activity android:name=".MainActivity">
...
</activity>
<!-- second icon -->
<activity-alias
android:name=".MainActivityAlias"
android:roundIcon="@drawable/ic_launcher_p_foreground"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher_second"
android:enabled="false"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>
</application>
this is a function to change the first icon into the second icon
private void changeIconToSecond() {
// disables the first icon
PackageManager packageManager = getPackageManager();
packageManager.setComponentEnabledSetting(new ComponentName(MainActivity.this, "com.radefffactory.appiconchange.MainActivity"),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
// enables the second icon
packageManager.setComponentEnabledSetting(new ComponentName(MainActivity.this, "com.radefffactory.appiconchange.MainActivityAlias"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
}
To return to the first icon
private void changeIconTOFirst() {
// disables the second icon
PackageManager packageManager = getPackageManager();
packageManager.setComponentEnabledSetting(new ComponentName(MainActivity.this, "com.radefffactory.appiconchange.MainActivity"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
// enables the first icon
packageManager.setComponentEnabledSetting(new ComponentName(MainActivity.this, "com.radefffactory.appiconchange.MainActivityAlias"),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
}

Elazar Halperin
- 133
- 1
- 13