I have an application that relies on push notifications to update users of events happening online. To do so, I have my normal Activity which displays the game to the user, and then a BroadcastReceiver which exists to process incoming push messages.
However, whenever we receive a message, it creates an instance of our Application. In our Application.onCreate() function we perform some preloading and processing logic that should only run when the Application being created is the actual Activity and not the BroadcastReceiver.
I also tried to move the processing and logic into the Activity.onCreate() but that whole lifecycle is much less predictable than that of the Application, so the Application method seems to be preferred, but I am open to alternate solutions.
How can I determine if the Application instance is being created for the BroadcastReceiver or Activity?