请在Android浏览器链接启动我的应用程序? [英] Make a link in the Android browser start up my app?

查看:132
本文介绍了请在Android浏览器链接启动我的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能做出这样一个链接:

 < A HREF =安东:// useful_info_for_anton_app>点击我< / A>!
 

因为我的安东的应用程序启动?

我知道这个作品与市场的协议,在Android Market的应用程序,但类似的东西与其他应用程序来完成?

下面是一个链接的一个例子,将启动Android市场:

 < A HREF =市场://搜Q = PNAME:com.nytimes.android!>点击我< / A>
 

更新: 我接受eldarerathis提供了答案的伟大工程,但我只是想指出,我遇到了一些麻烦与&LT的子元素的顺序;意向滤光器> 标记。我建议你​​只需将其他<意向滤光器> 在该标记的新的子元素,以避免我有问题。比如我的的Andr​​oidManifest.xml 是这样的:

 <活动机器人:名称=。AntonWorld
          机器人:标签=@字符串/ APP_NAME>
    <意向滤光器>
        <作用机器人:名称=android.intent.action.MAIN/>
        <类机器人:名称=android.intent.category.LAUNCHER/>
    &所述; /意图滤光器>
    <意向滤光器>
        <数据机器人:计划=安东/>
        <作用机器人:名称=android.intent.action.VIEW/>
        <类机器人:名称=android.intent.category.BROWSABLE/>
        <类机器人:名称=android.intent.category.DEFAULT/>
    &所述; /意图滤光器>
< /活性GT;
 

解决方案

我想你会想看看<一href="http://developer.android.com/guide/topics/manifest/intent-filter-element.html"><$c$c><intent-filter>您Mainfest文件的组成部分。具体来说,看一看的<一个文档href="http://developer.android.com/guide/topics/manifest/data-element.html"><$c$c><data>子元素

基本上,你需要做的就是定义自己的方案。线沿线的东西:

 &LT;意向滤光器&gt;
    &lt;数据机器人:计划=安东/&GT;
    &lt;作用机器人:名称=android.intent.action.VIEW/&GT;
    &LT;类机器人:名称=android.intent.category.DEFAULT/&GT;
    &LT;类机器人:名称=android.intent.category.BROWSABLE/&GT; &LT;  - 不是正面的,如果需要这一个
    ...
&所述; /意图滤光器&gt;
 

那么你应该能够推出与开头的链接您的应用程序安东: URI方案

Is it possible to make a link such as:

<a href="anton://useful_info_for_anton_app">click me!</a>

cause my Anton app to start up?

I know that this works for the Android Market app with the market protocol, but can something similar be done with other apps?

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>

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>

解决方案

I think you'll want to look at the <intent-filter> element of your Mainfest 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>

Then you should be able to launch your app with links that begin with the anton: URI scheme.

这篇关于请在Android浏览器链接启动我的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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