onReceive
onReceive is a callback method in Android's BroadcastReceiver class. It is invoked by the Android framework when a broadcast that matches the receiver’s intent filters is delivered, and it receives the Intent object carrying the action, data, and extras of the broadcast.
The canonical signature is public void onReceive(Context context, Intent intent). The context parameter provides access to
Execution and lifecycle considerations: onReceive runs on the main thread of the process. It should complete
Registration and scope: A BroadcastReceiver can be declared in the app’s manifest or registered dynamically at
Usage notes: Inside onReceive, developers typically inspect the action and extract extras from the intent to
See also BroadcastReceiver, Intent, IntentFilter, Service, WorkManager.