Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intent filter for launcher and send activity

I'm trying to get my main activity to be the launcher activity and also receive send events. Somehow I can't seem to make both work same time. Either I have the launcher icon in the app tray but then not in image share menu in from gallery for example. How can I make both work at the same time.

With this intent filter the icon is in app tray but not in share menu.

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

With this one I have it in the share but not in app tray

        <intent-filter>
            <category android:name="android.intent.category.LAUNCHER"/>
            <action android:name="android.intent.action.MAIN"/>
            <action android:name="android.intent.action.SEND" />
            <data android:mimeType="image/*" />
        </intent-filter>

I suspect it has something to do with the data element and I tried this but it didn't work

        <intent-filter>
            <category android:name="android.intent.category.LAUNCHER"/>
            <action android:name="android.intent.action.MAIN"/>
            <action android:name="android.intent.action.SEND" />
               <data android:mimeType="image/*">
            </action>  
        </intent-filter>

Any help much appreciated, thank you!

like image 385
Juhani Avatar asked Nov 24 '10 10:11

Juhani


People also ask

Can an activity have multiple intent filters?

To inform the system which implicit intents they can handle, activities, services, and broadcast receivers can have one or more intent filters.

What is intent filters explain intent filters with example?

An intent filter is an expression in an app's manifest file that specifies the type of intents that the component would like to receive. For instance, by declaring an intent filter for an activity, you make it possible for other apps to directly start your activity with a certain kind of intent.

What is the purpose of intent filter?

An intent filter declares the capabilities of its parent component — what an activity or service can do and what types of broadcasts a receiver can handle. It opens the component to receiving intents of the advertised type, while filtering out those that are not meaningful for the component.

What is the intent filter of main activity that launches your application main screen?

Multiple Intent Filters in Manifest File MAIN - It indicates the app's main entry point that means it starts the activity which defines with the MAIN action when the user initially launches the app with a launcher icon. LAUNCHER - It indicates that this activity icon should be placed on the home screen list of apps.


1 Answers

I found the solution. You can actually have more than one intent-filter tag in an action. So the right code was

        <intent-filter>
            <category android:name="android.intent.category.LAUNCHER"/>
            <action android:name="android.intent.action.MAIN"/>
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND"/>
            <data android:mimeType="image/*"/>
        </intent-filter>
like image 146
Juhani Avatar answered Sep 20 '22 09:09

Juhani