2

I looked up intent filters and found that they will be used when "Android finds the appropriate component to start by comparing the contents of the intent to the intent filters declared in the manifest file of other apps on the device"(http://developer.android.com/guide/components/intents-filters.html#Building)

In my manifest file, I have

<intent-filter>
        <action android:name="android.intent.action.MAIN" />

         <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

which from reading that guide means that this activity can handle an implicit intent with action of main and category of launcher.

However what if i have multiple applications with the same intent filter in the manifest file. I know that some implicit intent will be called with action of main and category of launcher. How does the Android O.S know to choose this application?

committedandroider
  • 8,711
  • 14
  • 71
  • 126

1 Answers1

3

when you have multiple activities defined with same intent filter(action=main and category=launcher), then android takes the first activity defined in the hierarchy with that intent filter (action=main and category=launcher) and will launch it when user clicks on app icon.

Rajen Raiyarela
  • 5,526
  • 4
  • 21
  • 41
  • hierarchy is in the order you defined in the android manifest. Suppose you have Activity1 and Activity2 with same intent filter but Activity2 is defined first and then you define Activity1 then Activity2 will be launched. – Rajen Raiyarela Jul 08 '14 at 06:40
  • @Rajn no, the OS will show the dialog with Activities matching the given intent filter, then you can choose what Activity to run – pskink Jul 08 '14 at 07:06
  • actually i replied with context to same application having two activities with same intent filter(action=main and category=launcher). But in case i request from my application to launch another application with particular intent action then your are cent percent right. – Rajen Raiyarela Jul 08 '14 at 07:31
  • the OP said "However what if i have multiple applications with the same intent filter in the manifest file.", multiple applications, not multiple home activities in the same app – pskink Jul 08 '14 at 07:50