意图过滤器,发射器和发送活动发射器、过滤器、意图

2023-09-06 08:51:25 作者:弃疗之后精神倍棒

我试图让我的主要活动将是发射活动,并接收发送事件。不知怎的,我似乎无法使双方的工作同时进行。无论是我从画廊例如在应用程序中的托盘不是在图像共享菜单的启动器图标,但随后。我怎样才能使双方的工作在同一时间。

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>

任何帮助非常AP preciated,谢谢!

Any help much appreciated, thank you!

推荐答案

我找到了解决办法。实际上,你可以在一个动作一个以上的意图过滤器标签。因此,正确的code是

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>