Multiple Activities showing as apps

Discussion in 'Application Development' started by krisjl20, Sep 1, 2012.

  1. krisjl20

    krisjl20 New Member
    5

    Sep 1, 2012
    1
    0
    5
    .NET Developer
    Michigan
    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
     

    Advertisement
  2. jonbonazza

    jonbonazza Well-Known Member
    163

    Jul 13, 2010
    1,934
    458
    163
    Male
    Yes, in your manifest file, you should have something like this:

    Code (Text):
    1.  
    2. <activity name=".MainActivityName" label="@string/app_name">
    3.       <intent-filter>
    4.                 <action android:name="android.intent.action.MAIN" />
    5.                 <category android:name="android.intent.category.LAUNCHER" />
    6.       </intent-filter>
    7. </activity>
    8.  
    9. <activity name=".AnotherActivityName" label="@string/app_name" />
    10.  
    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.
     
    krisjl20 likes this.

Share This Page

Loading...