views:

48

answers:

2

In my application I have a number of Activity classes. When I run on emulator (or install to a device) a corresponding number of program shortcuts show up in the programs menu. Why does this happen and how can I avoid it? Many thanks.

A: 

I think you need to look in your manifest file. I believe that is where the intents are defined.

David Radcliffe
Ah - I think I see - so I should use android.intent.category.LAUNCHER only for the activity that comprises the main entry point to the application; and some other category for the other activities?
AlanH
Yes - that is exactly what I was thinking. (I don't have my code in front of me)
David Radcliffe
Many thanks - that points me in the right direction at least.
AlanH
+2  A: 

I think you have added LAUNCHER attribute in every activity...so multiple shortcuts showing up in your program menu.

But, There should(mostly) only one "LAUNCHER" activity....
Do like Following:

    <activity android:name=".Testing"
              android:label="Showing Testing">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".Activity1"
              android:label="@string/Activity1">
    </activity>

    <activity android:name=".Activity2"
              android:label="@string/Activity2">
    </activity>
    <activity android:name=".Activity3"
              android:label="@string/Activity3">

    </activity>

</application>
PM - Paresh Mayani
Thank you Paresh - yes, I had figured this from David's answer. I have now changed so that there is only one "LAUNCHER". The other activities I have set the intent-filter to:<action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" />This works for me, but I don't know whether this is the most suitable setting and I need to read up on this aspect of Android development.
AlanH

related questions