Skip to content

Instantly share code, notes, and snippets.

@z8888q z8888q/gist:7280681
Last active Apr 11, 2019

Embed
What would you like to do?
How to change an application icon programmatically in Android
//1 . Modify your MainActivity section in AndroidManifest.xml, delete from it, line with MAIN category in intent-//filter section
<activity android:name="ru.quickmessage.pa.MainActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait"
android:label="@string/app_name"
android:theme="@style/CustomTheme"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />//DELETE THIS LINE
</intent-filter>
</activity>
<activity-alias android:label="@string/app_name"
android:icon="@drawable/icon"
android:name=".MainActivity-Red"
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>
getPackageManager().setComponentEnabledSetting(
new ComponentName("ru.quickmessage.pa", "ru.quickmessage.pa.MainActivity-Red"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
//不显示icon的代码如下
getPackageManager().setComponentEnabledSetting(
getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
//here is superuser.apk code
<activity android:theme="@style/Theme.Sherlock.Light" android:label="@string/app_name" android:icon="@drawable/transparent" android:name=".MainActivity" android:exported="true" android:excludeFromRecents="true" android:launchMode="singleTask" android:configChanges="locale|keyboard|keyboardHidden|orientation|screenLayout" android:noHistory="false" android:hardwareAccelerated="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity-alias android:label="@string/app_name" android:icon="@drawable/ic_launcher_emblem" android:name=".MainActivity-Emblem" android:enabled="true" 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:label="@string/app_name" android:icon="@drawable/ic_launcher_superandy" android:name=".MainActivity-SuperAndy" 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>
<activity-alias android:label="@string/app_name" android:icon="@drawable/ic_launcher_original" android:name=".MainActivity-Original" 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>
<activity-alias android:label="@string/app_name" android:icon="@drawable/ic_launcher_chip" android:name=".MainActivity-Chip" 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>
<activity-alias android:label="@string/app_name" android:icon="@drawable/ic_launcher_supersu" android:name=".MainActivity-SuperSU" 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>
@bigshotchina

This comment has been minimized.

Copy link

commented Feb 11, 2014

When component has been disabled, the app widget on launcher will be deleted also.

@prashantchau

This comment has been minimized.

Copy link

commented Mar 4, 2015

I want to simply change application icon from main activity.tell me code which is required in activity and in manifest file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.