Android的共享意向 [英] Android Sharing Intent

查看:308
本文介绍了Android的共享意向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法,我可以添加/列出我与其他应用程序,如Facebook,Gmail中,WhatsApp的和Viber的应用程序在Android共享意图?这里是样本图像

Is there any way I can add/list my app with other apps like facebook, gmail, whatsapp and viber in sharing intent on android .? here is the sample image

推荐答案

我不知道如何做到这一点用钛来完成,但在传统的方式(使用Eclipse),这是我要做的事在我的应用程序之一

I don't how this would be done using Titanium, but in the conventional way (using Eclipse), this is how I do it in one of my apps:

code:在清单的XML文件,添加标记,如下图所示。这是的活动将处理由用户共享的数据做。例如,如果我的活动被命名为 作曲 ,然后结构将是:

CODE: In your manifest XML file, add the tag as shown below. This is to be done for an Activity that will handle data shared by the user. For example, if my Activity is named Composer, then the structure would be:

<activity
    android:name=".Composer"
    android:exported="true"
    android:windowSoftInputMode="stateHidden|adjustResize" >

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

        <category android:name="android.intent.category.DEFAULT" />

        <data android:mimeType="text/plain" />
        <data android:mimeType="image/jpeg" />
        <data android:mimeType="image/png" />
    </intent-filter>
</activity>

code的说明:

EXPLANATION OF THE CODE:

这里的关键是在嵌套在数据标记&LT;意向滤光器&gt; 。如果我想我的应用程序上市的时候用户共享网络链接,在text / plain的用武之地。当我想要我的应用程序来处理图像,比如说,从画廊的应用程序中,图像/ JPEG图像/ PNG共享项发挥作用(的根据图像文件的扩展名的)。作为,然而,在OP随附的屏幕截图显示,如果你只需要分享网页链接的时候,那么&LT在浏览器让你的应用程序中列出;数据机器人:mime类型=text / plain的/方式&gt; 会为你做它

The key here are the data tags nested under the <intent-filter>. If I want my app listed when the user shares web links, the "text/plain" comes into play. When I want my app to handle Images shared from, say, the Gallery app, the "image/jpeg" and the "image/png" entries come into play (depending on the image file extension). As, however, indicated by the attached screenshot in the OP, if you only need to get your app listed in browsers when sharing web links, then the <data android:mimeType="text/plain" /> will do it for you.

同样,我不知道,如果code以上的作品,是钛。我从来没有使用过也没有阅读它。您的可能需要调整的有点如果在如何使用钛时做了区别。

Again, I do not know if the code above works as-is in Titanium. I have never used it nor have read up on it. You may have to tweak it a bit if there is a difference in how this is done when using Titanium.

这篇关于Android的共享意向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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