有多少方案和放大器;主机标签可以受到意图过滤器在Android清单 [英] How many scheme & host tags can come under intent-filter in android manifest

查看:113
本文介绍了有多少方案和放大器;主机标签可以受到意图过滤器在Android清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于需要在清单中指定意图过滤器标签的详细信息。我知道,我们可以有两种形式指定数据:

 <意向滤光器>
     <数据机器人:主机=com.myHost机器人:计划=内容/>
&所述; /意图滤光器>
 

 <意向滤光器>
     <数据机器人:计划=内容/>
     <数据机器人:主机=com.myHost/>
&所述; /意图滤光器>
 

不过,我想知道可以几种组合存在,就像

 <意向滤光器>
         <数据机器人:主机=com.myHost机器人:计划=内容/>
         <数据机器人:计划=内容/>
         <数据机器人:主机=com.myHost1/>
&所述; /意图滤光器>
 

 <意向滤光器>
         <数据机器人:主机=com.myHost机器人:计划=内容/>
         <数据机器人:计划=内容/>
         <数据机器人:主机=com.myHost1/>
         <数据机器人:计划=内容/>
         <数据机器人:主机=com.myHost2/>
&所述; /意图滤光器>
 

在最后一种情况下,我想知道,首先,如果这可以存在和放大器;它是如何决定哪台主机被用于何种方案,含有方案和放大器的数据标记;主机可以出现在任何顺序。

请帮忙。

解决方案
  

我知道,我们可以有两种形式指定数据。

不要使用内容的方案,除非你真正的意思是,你创建了一个支持的活动的ContentProvider

  

不过,我想知道能几种组合存在

如果您的过滤器只有一个属性<数据> ,你绝对可以有不同的价值观,像这样从联系人应用程序:

 <活动
        机器人:名称=。activities.ShowOrCreateActivity
        机器人:主题=@安卓风格/ Theme.Translucent.NoTitleBar>

        <意向滤光器>
            <作用机器人:名称=com.android.contacts.action.SHOW_OR_CREATE_CONTACT/>
            <类机器人:名称=android.intent.category.DEFAULT/>
            <数据机器人:计划=电子邮件地址/>
            <数据机器人:计划=电话/>
        &所述; /意图滤光器>
    < /活性GT;
 

此外,一个组件可以有多个<意向滤光器> 元素,其中的每一个逻辑或运算与他人(任何意图匹配任何过滤器是匹配的部件)。数据> 元素,我会倾向于把那些单独的<意向所以对于比较复杂的情况,那就是你有2+每个&LT属性 - 筛选> 元素

  

它是如何决定哪些主机将用于该计划

所有的比赛被认为是好的。你会检查意图自己更多地了解它包含的内容。

Need more info regarding intent-filter tag specified in manifest. I am aware that we can specify data in two forms:

<intent-filter>
     <data android:host="com.myHost" android:scheme="content"/>
</intent-filter>

AND :

<intent-filter>
     <data android:scheme="content"/>
     <data android:host="com.myHost"/>
</intent-filter>

But I wish to know can several combinations exist, like

<intent-filter>
         <data android:host="com.myHost" android:scheme="content"/>
         <data android:scheme="content"/>
         <data android:host="com.myHost1"/>
</intent-filter>

OR:

<intent-filter>
         <data android:host="com.myHost" android:scheme="content"/>
         <data android:scheme="content"/>
         <data android:host="com.myHost1"/>
         <data android:scheme="content"/>
         <data android:host="com.myHost2"/>
</intent-filter>

In the last case, I wish to know firstly if this can exist & how is it decided that which host to be used for which scheme, as the data tags containing scheme & host can occur in any order.

Please help.

解决方案

I am aware that we can specify data in two forms

Do not use content for a scheme, unless you truly mean that you are creating an activity in support of a ContentProvider.

But I wish to know can several combinations exist

If your filter has just one attribute for <data>, you definitely can have different values, such as this from the Contacts app:

    <activity
        android:name=".activities.ShowOrCreateActivity"
        android:theme="@android:style/Theme.Translucent.NoTitleBar">

        <intent-filter>
            <action android:name="com.android.contacts.action.SHOW_OR_CREATE_CONTACT" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="mailto" />
            <data android:scheme="tel" />
        </intent-filter>
    </activity>

Also, one component can have several <intent-filter> elements, each of which is logically OR'd with the others (any Intent matching any filter is a match for the component). So for more complex scenarios, where you have 2+ attributes per <data> element, I would be inclined to put those in separate <intent-filter> elements.

how is it decided that which host to be used for which scheme

Any match is considered good. You would examine the Intent yourself to learn more about what it contains.

这篇关于有多少方案和放大器;主机标签可以受到意图过滤器在Android清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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