Make a link in the Android browser start up my app?(在 Android 浏览器中创建一个链接来启动我的应用程序?)
问题描述
是否可以做如下链接:
<a href="anton://useful_info_for_anton_app">click me!</a>
导致我的 Anton 应用启动?
cause my Anton app to start up?
我知道这适用于具有市场协议的 Android Market 应用程序,但其他应用程序可以做类似的事情吗?
I know that this works for the Android Market app with the market protocol, but can something similar be done with other apps?
以下是启动 Android Market 的链接示例:
Here is an example of a link that will start up the Android Market:
<a href="market://search?q=pname:com.nytimes.android">click me!</a>
更新:eldarerathis 提供的我接受的答案效果很好,但我只想提一下,我在 <intent-filter>
标记的子元素的顺序上遇到了一些问题.我建议您只需使用该标记中的新子元素制作另一个 <intent-filter>
以避免我遇到的问题.例如我的 AndroidManifest.xml
看起来像这样:
Update:
The answer I accepted provided by eldarerathis works great, but I just want to mention that I had some trouble with the order of the subelements of the <intent-filter>
tag. I suggest you simply make another <intent-filter>
with the new subelements in that tag to avoid the problems I had. For instance my AndroidManifest.xml
looks like this:
<activity android:name=".AntonWorld"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="anton" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
推荐答案
我想你会想看看 <intent-filter>
清单文件的元素.具体来说,请查看 <data> 的文档;
子元素.
I think you'll want to look at the <intent-filter>
element of your Manifest file. Specifically, take a look at the documentation for the <data>
sub-element.
基本上,您需要做的是定义自己的方案.大致如下:
Basically, what you'll need to do is define your own scheme. Something along the lines of:
<intent-filter>
<data android:scheme="anton" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <--Not positive if this one is needed
...
</intent-filter>
然后您应该能够使用以 anton:
URI 方案开头的链接启动您的应用程序.
Then you should be able to launch your app with links that begin with the anton:
URI scheme.
这篇关于在 Android 浏览器中创建一个链接来启动我的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Android 浏览器中创建一个链接来启动我的应用程序?


- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01