16

What is the integer value the gives a broadcast receiver the highest priority?

<intent-filter android:priority="1">
  <action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
Tunaki
  • 132,869
  • 46
  • 340
  • 423
confucius
  • 13,127
  • 10
  • 47
  • 66

6 Answers6

25

Well, according to the documentation

"The value must be an integer, such as "100". Higher numbers have a higher priority."

So I'm guessing that any integer value is valid. And the highest priority possible would be the maximum integer that android allows, which is (2^31 - 1).

EDIT

The documentation has been updated, and it now explicitly states which priority values may be used by applications. The documentation now says

SYSTEM_HIGH_PRIORITY (1000): Applications should never use filters with this or higher priorities. SYSTEM_LOW_PRIORITY (-1000): Applications should never use filters with this or lower priorities.

Implying that your application is permitted to use integer priority levels between -999 and 999.

theisenp
  • 8,639
  • 5
  • 39
  • 47
19

Well the system highest priority is 1000. You can refer to this link to know more.

wasaig
  • 666
  • 5
  • 18
  • 8
    No, it's 999. `SYSTEM_HIGH_PRIORITY (Constant Value: 1000) Applications should never use filters with this or higher priorities.` – Nirmal Jun 05 '14 at 17:45
5

Actually, numbers above 1000 grant more priority, despite the documentation. So the highest integer number(2147483647) grants more priority.

Shayan_Aryan
  • 2,002
  • 1
  • 29
  • 31
2

Google suggests that: 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.http://developer.android.com/guide/topics/manifest/intent-filter-element.html But in the projects, we often use the highest integer number(2147483647) (2 ^32-1)) or others;it is helpful.

2

999 gives a broadcast receiver the highest priority.

As per Android Documentation: Applications must use a value that is larger than SYSTEM_LOW_PRIORITY and smaller than SYSTEM_HIGH_PRIORITY. The value of SYSTEM_HIGH_PRIORITY is 1000.

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

Varun
  • 1,938
  • 18
  • 19
2

Applications should avoid using filters with "this" or higher priorities. "this" refers to the value "1000"

Anup Cowkur
  • 20,443
  • 6
  • 51
  • 84
AlucardHAX
  • 21
  • 1