让Android应用程序倾听共享链接 [英] Make Android app listen to shared links

查看:106
本文介绍了让Android应用程序倾听共享链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的Andr​​oid应用程序出现列为当用户从其他应用程序(如浏览器)共享的URL的选项。如何注册我的应用程序做到这一点?我怎样才能应对链接股份?

I want my Android app to appear listed as an option when the user shares an URL from another app (like the browser). How can I register my app to do that? How can I react to link shares?

多谢了。

编辑:

我使用的IntentFilter这样已经尝试没有成功:

I've tried using IntentFilter like this without success:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

任何想法?

推荐答案

在非常最低限度,你需要:

At the very bare minimum you need:

<activity android:name=".ShareActivity">
    <intent-filter
        android:label="Share with my app">
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

在你的清单......这至少会使其显示在分享上市。

in your manifest...which will at least make it show up in the 'share' listing.

你错过了最重要的部分是:

The most important part you are missing is:

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

要让它真正做一些事情,你需要一个活动。

To make it actually do something, you need an Activity.

这可以帮助过: <一href="http://sudarmuthu.com/blog/sharing-content-in-android-using-action_send-intent">http://sudarmuthu.com/blog/sharing-content-in-android-using-action_send-intent

其他信息:

<activity android:name=".ShareActivity">
<intent-filter
    android:label="Share with my app">
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
</intent-filter>
</activity>

在那里,&lt;数据机器人:MIMETYPE 将限制你什么回应,如果你想限制你的应用程序的响应

There the <data android:mimeType will limit what you respond to, if you want to limit your app's response.

这篇关于让Android应用程序倾听共享链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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