IntentFilter 中 的android:priority 的含义

网上很多文章中都写到这样一种方法,提高service的优先级别可以用android:priority = “1000” 的方式来提供servie 的存活时间。其实这是一种没有效果的做法(具体做法可参考service能否实现不被kill)

关于priority 这个属性的描述 ,google 官方文档如下:

android:priority
The priority that should be given to the parent component with regard to handling intents of the type described by the filter. This attribute has meaning for both activities and broadcast receivers:
It provides information about how able an activity is to respond to an intent that matches the filter, relative to other activities that could also respond to the intent. When an intent could be handled by multiple activities with different priorities, Android will consider only those with higher priority values as potential targets for the intent.
It controls the order in which broadcast receivers are executed to receive broadcast messages. Those with higher priority values are called before those with lower values. (The order applies only to synchronous messages; it's ignored for asynchronous messages.)
Use this attribute only if you really need to impose a specific order in which the broadcasts are received, or want to force Android to prefer one activity over others.

The value must be an integer, such as "100". Higher numbers have a higher priority. The default value is 0. The value must be greater than -1000 and less than 1000.

Also see setPriority().

1. 优先级的概念用于描述控件的 intent的filter的类型。 这个属性只对activity 和 receivers 是有意义的。

2. 隐式调用activity的情况下: 如果多个activity 满足响应 的条件,   系统只会触发 priority 高的那个activity。

3. 有序广播发出的情况下:如果多个receiver满足响应的条件,系统会优先触发prioriyt搞的那个receiver。

4. priority 必须是整数,默认是0    范围是[-1000, 1000]


http://developer.android.com/guide/topics/manifest/intent-filter-element.html


你可能感兴趣的:(android,C)