Search code examples
androidbroadcastreceiverbroadcast

Possible to set BroadcastReceiver priority programmatically?


Is it possible to set the priority attribute of a BroadcastReceiver programmatically or can it only be done in XML? Relevant documents include:

http://developer.android.com/reference/android/content/BroadcastReceiver.html

http://developer.android.com/reference/android/R.styleable.html

It doesn't seem so, but I don't fully understand the relationship of android.R.styleable to a given application and its activities...


Solution

  • You don't set priority on BroadcastReceiver (or Activity) objects, but instead on the IntentFilter object(s) that cause these items to be started.

    With that in mind, IntentFilter.setPriority() is what you want to use.