启动器和发送活动的意图过滤器 [英] Intent filter for launcher and send activity

查看:28
本文介绍了启动器和发送活动的意图过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的主要活动成为启动器活动并接收发送事件.不知何故,我似乎无法让两者同时工作.例如,我在应用程序托盘中有启动器图标,但在图库中的图像共享菜单中没有.我怎样才能让两者同时工作.

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.

使用此 Intent 过滤器,图标位于应用托盘中,但不在共享菜单中.

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!

推荐答案

我找到了解决方案.您实际上可以在一个操作中拥有多个意图过滤器标签.所以正确的代码是

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>

这篇关于启动器和发送活动的意图过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆