Android Tutorial One App - Two Activities (or more) - Two launcher icons

For my latest wear app i needed two different launcher icons, each one starting one different activity of the same app. It's really easy to accomplish, it only needs to edit the manifest file.

Let's assume we have an app with package name com.new.test and two activities act1, act2 and act1 is the main activity for which we have the intent filter ready in the manifest from b4a and which starts when the user clicks the launcher icon of our app. We want to add a second launcher icon which starts the second activity act2. What we need to do is open the manifest editor and add the following
B4X:
SetActivityAttribute(act1, android:taskAffinity, "com.new.test.act1")

SetActivityAttribute(act2, android:taskAffinity, "com.new.test.act2")
SetActivityAttribute(act2, android:label, "Caption under new activity icon")

AddActivityText(act2,
<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>)

Hope it helps!
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…