I am trying to update the state of the user interface when receiving a push notification. To do this, I need to run AsyncTask, which performs some network operations, and then updates the user interface based on the result.
According to the documentation, BroadcastReceiverexecuting asynchronous operations at the receiver is unsafe because the process executing it can be killed as soon as it onReceive()returns, assuming there are no other “application components” in this process.
Does it work BroadcastReceiverin its own process or in the same process as containing activity? Since I only care about completing the task while the user interface is being updated, I don’t worry about death AsyncTaskif the activity is closed. Assuming BroadcastReceiver is in the same process as activity, does it make it safe / secure to run the task that I described in the receiver?
Edit:
To clarify, I register the recipient in action onResume()and do not register him onPause(), so he should only receive intentions when the activity is already active.
source
share