Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 208
ashok reddy Avatar asked Dec 10 '12 06:12

ashok reddy


People also ask

Can an activity have multiple Intent filters?

If it fails to match even one of them, the Android system won't deliver the intent to the component. However, because a component may have multiple intent filters, an intent that does not pass through one of a component's filters might make it through on another filter.

Which components can you specify in an Intent filter?

Each <data> element can specify a URI and a data type (MIME media type). There are separate attributes like scheme, host, port, and path for each part of the URI. An Intent object that contains both a URI and a data type passes the data type part of the test only if its type matches a type listed in the filter.

What are the two Intent types in android?

There are two intents available in android as Implicit Intents and Explicit Intents.


1 Answers

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> 
like image 74
gsingh2011 Avatar answered Sep 27 '22 21:09

gsingh2011