android - http 方案 Intent 过滤器,用于从网络链接到应用程序

标签 android android-intent intentfilter

这似乎是一个典型的问题,似乎有很多不同的行为,但我遇到的问题是,我的方案将启动选择器并允许我在点击某个链接时选择我的应用程序电子邮件或设备上的注释,但如果我点击网页上的链接,我似乎无法启动该应用程序,甚至无法获得选择器(我检查了两个浏览器的“默认值”,但没有已设置)。

<activity
                android:name=".MyActivity" 
                android:exported="true"
                android:enabled="true">
                <intent-filter>
                    <data android:scheme="http" android:host="www.website.com"/>
                    <data android:scheme="http" android:host="website.com"/>
                    <action android:name="android.intent.action.VIEW" />
                    <category android:name="android.intent.category.DEFAULT" />
                    <category android:name="android.intent.category.BROWSABLE" />
                </intent-filter>
    </activity>

如果我使用下面的电子邮件中的链接之一,它会给我选择器,启动我的应用程序,一切都很好,但是,在网络浏览器中点击相同的链接只会启动没有选择器的页面。关于可能出现的问题有什么建议吗?

http://www.website.com/share.aspx?id=12345678

使用 Chrome 和原生浏览器在运行 ICS 4.0.3 的 GS2 上进行测试。

最佳答案

添加 android:pathPrefix 属性。

<data android:scheme="http" android:host="website.com" android:pathPrefix="/" />

关于android - http 方案 Intent 过滤器,用于从网络链接到应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11562534/

相关文章:

android - 如何使用 Intent 中的附加功能

android - android中的 Activity 流程

Android SQLite 问题 "Cannot perform this operation because the connection pool has been closed"

java - 有没有人得到压缩来使用 ASmack

java - 错误 : Execution failed for task ':app: lintVitalRelease' any one can solve it?

android - 使用 onActivityResult 时如何清除 Activity 历史记录

android - 尝试将文件从 SD 卡附加到电子邮件

android - IntentService 未被调用

Android TabHost选项卡背景高度较小

Android - ListView - 按需调用 getView()