Dav*_*son 4 android intentfilter android-intent
所以我点击这个链接:
<a href="intent://www.google.com#Intent;scheme=http;action=android.intent.action.VIEW;end">Google</a>
Run Code Online (Sandbox Code Playgroud)
(我知道这是一个愚蠢的例子,因为它可能只是http://www.google.com,但它说明了问题)
我确定了这个URI
Log.v(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://www.google.com")).toUri(
Intent.URI_INTENT_SCHEME));
Run Code Online (Sandbox Code Playgroud)
我在logcat中看到以下内容:
08-02 08:32:34.708 I/ActivityManager( 71): Starting activity: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=http://www.google.com cmp=com.android.browser/.BrowserActivity }
08-02 08:32:34.748 E/Tab ( 4188): onReceivedError -10 intent://www.google.com#Intent;scheme=http;action=android.intent.action.VIEW;end The protocol is not supported
Run Code Online (Sandbox Code Playgroud)
而不是重定向到www.google.com我得到"网页不可用"页面.
如果我使用am二进制文件启动相同的意图,它会成功.
adb -e shell am start -d http://www.google.com -a android.intent.action.VIEW
Run Code Online (Sandbox Code Playgroud)
我在logcat中看到了这个
08-02 08:47:42.488 I/ActivityManager( 71): Starting activity: Intent { act=android.intent.action.VIEW dat=http://www.google.com flg=0x10000000 cmp=com.android.browser/.BrowserActivity }
Run Code Online (Sandbox Code Playgroud)
最终目标是拥有一个在应用程序中启动特定活动的URL(并且在没有安装应用程序的情况下,某人无法访问此页面).我知道我也可以定义一个自定义方案,但由于它是一个全局命名空间,我宁愿不这样做.我也知道我可以使用http://为此目的,但我不希望系统提示用户是否要在浏览器或我的应用程序中打开URL.
有任何想法吗?
我遇到了同样的问题
将以下代码添加到AndroidManifest.xml中的Activity,解决了我的问题:
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4954 次 |
| 最近记录: |