Android Interview Questions and Answers What is android?


Registering And Unregistering BroadcastReceivers Dynamically



Download 0.77 Mb.
View original pdf
Page42/62
Date17.12.2020
Size0.77 Mb.
#54986
1   ...   38   39   40   41   42   43   44   45   ...   62
Android Interview Questions
4. Registering And Unregistering BroadcastReceivers Dynamically
4.1 Registration
A BroadcastReceiver can be registered dynamically using an implementation of the android.content.Context public abstract Intent registerReceiver(
BroadcastReceiver receiver,
IntentFilter filter,
String broadcastPermission,
Handler scheduler) method.

If the broadcastPermission argument is non-null then the registered BroadcastReceiver cannot receive broadcast Intents from any Application which has not been granted the specified permission. If the scheduler argument is non-null then the registered BroadcastReceiver’s onReceive() method will be executed in the context of the specified Handler. If it is not necessary to specify either a permission or a Handler then an implementation of the android.content.Context public abstract Intent registerReceiver(
BroadcastReceiver receiver,
IntentFilter filter) method can be used instead. Both methods will return either a broadcast Intent which was sent in sticky mode which matches the given
IntentFilter, or null. (See also. Both methods can also be used to access a stick broadcast Intent directly
The same BroadcastReceiver can be registered multiple times with different IntentFilters.

Download 0.77 Mb.

Share with your friends:
1   ...   38   39   40   41   42   43   44   45   ...   62




The database is protected by copyright ©ininet.org 2024
send message

    Main page