Change Application name and launcher icon runtime.

Changing an application name and application icon from the application.

For that we need to use the <activity-alias>. This tag will be in manifest inside <application> tag.

<activity-alias android:enabled=["true"|"false"]
android:exported=["true"|"false"]
android:icon="drawable"
android:label="string resource"
android:name="string resource"
android:permission="string resource"
android:targetActivity="string resource">

</activity-alias>

An alias for an activity, named by the targetActivity attribute. The target must be in the same application as the alias and it must be declared before the alias in the manifest.

The alias presents the target activity as a independent entity. It can have its own set of intent filters, and they, rather than the intent filters on the target activity itself, determine which intents can activate the target through the alias and how the system treats the alias. For example, the intent filters on the alias may specify the “android.intent.action.MAIN” and “android.intent.category.LAUNCHER” flags, causing it to be represented in the application launcher, even though none of the filters on the target activity itself set these flags.

With the exception of targetActivity, <activity-alias> attributes are a subset of <activity> attributes. For attributes in the subset, none of the values set for the target carry over to the alias. However, for attributes not in the subset, the values set for the target activity also apply to the alias.

getPackageManager().setComponentEnabledSetting(new ComponentName("com.sid.appiconlauncher", "com.sid.appiconlauncher.MainActivity-Red"),

PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);

    try {
        getPackageManager().setComponentEnabledSetting( new ComponentName("com.sid.appiconlauncher", "com.sid.appiconlauncher.MainActivity-Green"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
        getPackageManager().setComponentEnabledSetting( new ComponentName("com.sid.appiconlauncher", "com.sid.appiconlauncher.MainActivity-Blue"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    } catch (Exception e) {
        e.printStackTrace();
    } 

Source code Download Here

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s