I have noticed that when I send a push notification (Firebase Messaging Service) to my device my Application object is created. This is without clicking on the notification. Simply the act of viewing the notification creates the application. Further, it also starts the Jetpack AppStartup library. I want to be able to use AppStartup and application create. But I don't want to launch that code when a push notification occurs.
Why does Android do this? Is this part of all android notification, or is it a feature of the third-party push notification sdk I am using? And is there a way in Application.create and AppStartup to distinguish a normal app launch from a push notification triggered launch?
Again, I'm not talking about the user clicking on the notification (and launching the app because of a deeplink). I'm talking about just looking at the notification in the notification dropdown.
Android is starting your app process to run code in your app. Creating an
Applicationinstance and callingonCreate()will be part of that, as will creating anyContentProviderobjects. IIRC, Jetpack Startup uses aContentProviderto get control early in your process, though I am not 100% certain of that.The reason why Android is starting your app process is because your app is causing the
Notificationto be displayed — specifically, Firebase Cloud Messaging is doing that. If I remember the protocol correctly, Play Services is sending a broadcastIntentthat Firebase Cloud Messaging in your app will respond to, and part of that code will be displaying theNotification.onCreate()of anApplicationsubclass has no means of knowing what specifically caused the process to be created, as there can be many possible reasons. If by "AppStartup" you mean Jetpack Startup, I do not recall it having any options here, but I have not spent much time with its API.