如何处理浏览器的"分享网页"意图在Android的? [英] How do I handle the browser's "share page" intent in android?

查看:104
本文介绍了如何处理浏览器的"分享网页"意图在Android的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到这里(<一href="http://androidlittle.blogspot.com/2009/08/intent-filter-for-share-link.html">http://androidlittle.blogspot.com/2009/08/intent-filter-for-share-link.html )有什么意图过滤器需要处理的分享链接的意图是,Android的网页浏览器发送。我把这样的一个块中在我的Andr​​oidManifest.xml像这样:

I read here ( http://androidlittle.blogspot.com/2009/08/intent-filter-for-share-link.html ) what intent-filter is required to handle the "share link" intent that the android web browser sends. I have placed this inside an block in my AndroidManifest.xml like so:

    <activity android:name=".ShareLink">
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
        </intent-filter>
        <meta-data/>
    </activity>

我不能为我的生命得到这个被触发,虽然。当我分享在Android浏览器中的链接,该仿真器日志显示它创建一个选择器的意图,但并没有给意图选择器作用于细节。没有选择器窗口弹出,并意图得到由SMS应用程序进行处理。

I cannot for the life of me get this to be triggered though. When I share a link in the android browser, the emulator log shows it's creating a chooser intent, but doesn't give the details of the intent the chooser is acting on. No chooser window pops up, and the intent gets handled by the SMS application.

我也尝试过手动拉开意图:

I have also tried kicking off the intent manually:

adb shell am start -D -a android.intent.action.SEND -c android.intent.category.DEFAULT -t text/plain -d http://google.com/

但我得到的回应是:

but the response I get is:

Starting: Intent { act=android.intent.action.SEND cat=[android.intent.category.DEFAULT] dat=http://google.com/ typ=text/plain }
Error: Activity not started, unable to resolve Intent { act=android.intent.action.SEND cat=[android.intent.category.DEFAULT] dat=http://google.com/ typ=text/plain flg=0x10000000 }

谁能告诉我什么,我做错了吗?我的主要(发射器)活动工作正常,所以我认为没有问题,在模拟器上安装。

Can anyone tell me what I'm doing wrong? My main (launcher) activity works fine, so I assume there is no issue with installation on the emulator.

推荐答案

哎呦!

事实证明,我已经装了最初的方案,但重新安装后,它静静地失败。在这两者之间的两个版本我固定清单是因为你看到的上面 - 已安装的版本并没有意图过滤器指定的,这显然是行不通的。

Turns out, I had got the package installed initially but upon reinstallation it was silently failing. In between those two builds I fixed the manifest to be as you see above - the installed version didn't have the intent-filters specified, which obviously wouldn't work.

我想我会在这里离开这个万一有人有同样的需要?或者我应该删除它?

Guess I'll leave this here in case someone has the same need? Or should I just delete it?

这篇关于如何处理浏览器的&QUOT;分享网页&QUOT;意图在Android的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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