I want a piece of code to be executed only when my app is launched or resumed. The problem is that I cannot use the onCreate()
and onResume()
methods because there is navigation between Activities
within the app and the things I want to do must be done only when the app is launched or resumed.
Let's take an example, suppose there is an App which has Activities "A", "B" and "C" and user can navigate between these activities. I don't want to know when user has started activity "A", "B" or "C". What I want to know is when the user launched or resumed the "APP". Even clearer, if the main Activity is "A", let's imagine this navigation cycle Opens APP -> (1) Activity "A" -> (2) Activity "B" -> (3) Activity "A"
, then I would want this code to be executed only on (1)
.