Setting different icons for different activities of the same app

Inman

Well-Known Member
Licensed User
Longtime User
I am developing an app that would have 2 icons in the launcher (just like Google Maps which has Maps and Places). In the official Android documentation, it is mentioned that activities can have their own android:icon element. So I did the following in the Manifest file:

B4X:
 <application android:icon="@drawable/icon" android:label="Browserapp">
<activity android:windowSoftInputMode="stateHidden" android:launchMode="singleTop" android:name=".main"
                  android:label="Browser" android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
</activity>
                
<activity android:windowSoftInputMode="stateHidden" android:launchMode="singleTop" android:name="Launcher" android:icon="@drawable/launcher" android:label="Browser Launcher" android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
</activity>

In the Objects\res\drawable folder, I put 2 files - icon.png and launcher.png. The main activity gets icon.png correctly. I was hoping by giving android:icon="@drawable/launcher" it would select launcher.png in the drawable folder for the activity named Launcher, just like how it picked icon.png in drawable folder for the main activity. But instead I get the error

AndroidManifest.xml:42: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/launcher').

Also the file launcher.png gets deleted automatically as well, as soon as I get this error. Or may be that happened first, which triggered this error. Either way, the file gets deleted and I get the error. Any idea what went wrong here?
 
Last edited:

bluejay

Active Member
Licensed User
Longtime User
The Basic4Android IDE likes to regenerate all files in the standard Android folders and delete any files it does not recognize from these folders.

Make both png files Read Only.

bluejay
 
Upvote 0
Top