1

In my custom Application class, I want to know the reason that the app was launched. For example, was it launched because of a remote notification, the user launched the app directly, etc.
On iOS, When the application launches I can use the LaunchOptionsKey in the application(_:didFinishLaunchingWithOptions:) method in order to know the reason the app was launched.

launchOptions.
A dictionary indicating the reason the app was launched (if any).

Is there any equivalent on Android?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Tomer Hadad
  • 62
  • 1
  • 5
  • 1
    What is a "remote notification"? Do you mean Firebase Cloud Messaging? In general, there is no way to determine from `Application` why your process was started, but your entry points (e.g., launcher activity, Firebase Cloud Messaging service, etc.) will find out when they get called. – CommonsWare Nov 22 '20 at 14:55
  • i think it is mainly from the intent object. For push notification specifically, you can checkout this question: https://stackoverflow.com/questions/22794570/how-to-know-if-the-app-was-launched-by-clicking-on-the-push-notification this question is about how to set and get the extra data from intent: https://stackoverflow.com/questions/4233873/how-do-i-get-extra-data-from-intent-on-android – Surely Nov 22 '20 at 15:36

0 Answers0