Android Question Is possible programmatically change application icon and label ?

tucano2000

Active Member
Licensed User
Longtime User
I need to change the launcher icon and label of my app to Pro version. Is possible ?

I found this for Java but i don´t know to translate to B4A :

1 . Modify your MainActivity section in AndroidManifest.xml, delete from it, line with MAIN category in intent-filter section

B4X:
<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" /> <== Delete this line
        <category android:name="android.intent.category.LAUNCHER" />//DELETE THIS LINE
    </intent-filter>
</activity>

2 . Create <activity-alias>, for each of your icons. Like this

B4X:
<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>

3 . Set programmatically: set ENABLE attribute for the appropriate activity-alias

B4X:
getPackageManager().setComponentEnabledSetting(
        new ComponentName("ru.quickmessage.pa", "ru.quickmessage.pa.MainActivity-Red"),
            PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);

Source: http://stackoverflow.com/questions/...-application-icon-programmatically-in-android


In B4A I think it is necessary to change only step 3. Anyone know how to do this?

I'm Brazilian...Sorry my bad english. :(
 
Last edited:
Top