I have an application that contains two Activities with
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
in the manifest. I did this so that there are 2 separate entries in the app drawer. It functions properly with regards to the app drawer as it is.
My question comes during the install. After you install an app with only one MAIN/LAUNCHER activity the last page has an open button that will launch the app that was just installed. With my app this open button is greyed out. I assume it is because it doesn't know which of the two activities I would want it to launch if the open button were pressed. Is there anything I can set in the manifest(or elsewhere) to specify which activity I'd like the open button to launch at the end of the install process? I am thinking there must be something I can set, because when I install the app through adb with eclipse it launches one of the two activities and luckily it is actually the one that I would like it to launch.
On latest Android versions - If there are more than one launcher activities and if we don't put this category tag then the activity which is mentioned first in the Android manifest file will get launched as start-up activity.
Yes, You can have more than one launcher activity in your application. This will not create any kind of compile-time or run time error. You will find two launcher logos of your application in your device can launch different activities as we defined in manifest.
Launcher Activities are the activities that can be launched for a given intent. For example, when you press an app icon on the home screen, the StartActivity intent starts the activity you have specified as the launcher activity.
If both application have the same signature (meaning that both APPS are yours and signed with the same key), you can call your other app activity as follows: Intent LaunchIntent = getActivity(). getPackageManager(). getLaunchIntentForPackage(CALC_PACKAGE_NAME); startActivity(LaunchIntent);
This question:
After downloading an application with two Launcher components from the Marketplace, clicking "Open" will cause a crash
Helped me to get it working how I wanted. The key was adding:
<activity-alias android:name="com.android.internal.app.ResolverActivity"
android:targetActivity=".Main" android:exported="true">
</activity-alias>
to the manifest and changing ".Main" to reference the activity that you wish to start with the open button at the end of install.
Note that the activity-alias tag must be declared after the activity tag you are referring to (in the xml).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With