Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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...

like image 346
ChaimKut Avatar asked May 04 '10 18:05

ChaimKut


People also ask

Which method will be called when intent broadcast shall be received by BroadcastReceiver?

A broadcast receiver is implemented as a subclass of BroadcastReceiver class and overriding the onReceive() method where each message is received as a Intent object parameter.

What is the role of the onReceive () method in the BroadcastReceiver?

Retrieve the current result extra data, as set by the previous receiver. This can be called by an application in onReceive(Context, Intent) to allow it to keep the broadcast active after returning from that function.

What is the difference between service and BroadcastReceiver in Android?

A Service receives intents that were sent specifically to your application, just like an Activity. A Broadcast Receiver receives intents that were broadcast system-wide to all apps installed on the device.


1 Answers

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.

like image 54
Christopher Orr Avatar answered Nov 02 '22 19:11

Christopher Orr