开发者

Intent filter for launcher and send activity

开发者 https://www.devze.com 2023-01-26 22:18 出处:网络
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 the

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.ca开发者_开发百科tegory.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!


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消