Android Interview Questions and Answers What is android?



Download 0.77 Mb.
View original pdf
Page43/62
Date17.12.2020
Size0.77 Mb.
#54986
1   ...   39   40   41   42   43   44   45   46   ...   62
Android Interview Questions
4.2 Unregistration
A dynamically registered BroadcastReceiver can be unregistered using an implementation of the android.content.Context public abstract void unregisterReceiver(BroadcastReceiver receiver) The effect of this method is undo the effects of all calls to either of the registerReceiver() methods used to register the given BroadcastReceiver.
5. BroadcastReceiver Lifecycles
The lifecycle of a BroadcastReceiver differs depending upon whether it was registered statically or dynamically
5.1 The Static BroadcastReceiver Lifecycle
The lifecycle of a statically registered BroadcastReceiver is under the control of the System. When a broadcast Intent is to be delivered to a statically registered BroadcastReceiver the System will
1. create the appropriate process in which to run it if necessary
2. create an instance of the BroadcastReceiver and invoke its onReceive() method Once the onReceive() method has returned the System may stop the process used to run it.

The transient nature of a statically registered BroadcastReceiver means that its onReceive() method cannot use any functionality which is asynchronous, for example, binding to a Service
This constraint is enforced by the implementation of the Context passed to the method at runtime. For example, its implementation of the bindService()
method throws a RuntimeException.

Download 0.77 Mb.

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




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

    Main page