Search code examples
androidintentfilter

How to mention two intent filters for An activity in android


I am writing an application to open HTML files so i am mentioning the intent filter for activity as

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

            <category android:name="android.intent.category.DEFAULT" />

            <data android:mimeType="text/html" />
        </intent-filter>

,for this app, no launcher icon will be there.but i want my application to be as launcher app and when i open the app i want to display some info about application,and then he open the app by html file then i want to do different functionality (parsing the html).any ideas?


Solution

  • You can specify more than one <intent-filter> between the <activity> tags:

    <activity android:name=".MyActivity">
      <intent-filter>
         <action android:name="android.intent.action.MAIN" />
         <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="text/html" />
      </intent-filter>
    </activity>