• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Multiple Activities showing as apps

My Background. Currently I am a .NET Developer working mainly with databases. Taking an interest in Android development by creating my first app. To understand it all, I am just trying to create a data collection application.

For example, collecting user information. My main activity will show a list of users and a button to add a new user. So, I created a new activity for the add a new user form.

I am using eclipse, with the normal AVD (ARM (armeabi-v7a)). I can successfully take the user to the add new form, no real issues with that. However, when I run the app in the AVD, I see my main activity (or the actual app) and the add new user activity as an app.

Why is that? Is there some way to define the main activity for the app?

Thanks in advance,
Kris
 
Yes, in your manifest file, you should have something like this:

Code:
<activity name=".MainActivityName" label="@string/app_name">
      <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
</activity>

<activity name=".AnotherActivityName" label="@string/app_name" />

Notice the intent filter in the first one. the android.intent.action.main value in the name field tells the system that it's the main activity
the android.intent.category.LAUNCHER value for the category field tells the system that the activity should be placed in the launcher.

Now, notice how the second activity has neither. It will not be designated as the main activity, nor will it be placed in the launcher.
 
  • Like
Reactions: krisjl20
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones