可以通过编程方式设置BroadcastReceiver优先级吗?

Cha*_*Kut 16 android broadcast broadcastreceiver

是否可以通过编程方式设置BroadcastReceiver的优先级属性,还是只能以XML格式完成?相关文件包括:

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

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

它似乎不是这样,但我不完全理解android.R.styleable与给定应用程序及其活动的关系......

Chr*_*Orr 39

您不要在BroadcastReceiver(或Activity)对象上设置优先级,而是在IntentFilter导致这些项启动的对象上设置优先级.

考虑到这一点,IntentFilter.setPriority()就是你想要使用的.