Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What does goasync do in android broadcastreceiver?


Asked by Michelle Compton on Nov 30, 2021 Android



Since Android API 11 you can call the goAsync () method. This method returns an object of the PendingResult type. The Android system considers the receiver as alive until you call the PendingResult.finish () on this object.
In this manner,
Alternatively to this static registration, you can also register a receiver dynamically via the Context.registerReceiver () method. The implementing class for a receiver extends the BroadcastReceiver class. If the event for which the broadcast receiver has registered happens, the onReceive () method of the receiver is called by the Android system.
In addition, Since Android API 11 you can call the goAsync () method. This method returns an object of the PendingResult type. The Android system considers the receiver as alive until you call the PendingResult.finish () on this object. With this option you can trigger asynchronous processing in a receiver.
In respect to this,
Receiving broadcasts 1 Manifest-declared receivers. If you declare a broadcast receiver in your manifest, the system launches your app (if the app is not already running) when the broadcast is sent. 2 Context-registered receivers. Create an instance of BroadcastReceiver . ... 3 Effects on process state. ...
Just so,
The system creates a new BroadcastReceiver component object to handle each broadcast that it receives. This object is valid only for the duration of the call to onReceive (Context, Intent). Once your code returns from this method, the system considers the component no longer active.