I have to run a process of my app immediately when the app starts. I know about the onCreate
method, but it gets called every time the activity is created. Is there an onCreate
method for the entire app itself?
Say I want to run a process, we can call it A, at the start of an app. I would normally put it at the very first activity of my app, in the onCreate
, but that gets called multiple times, whenever I go back to my first activity.
1. App starts->
2. First Activity starts->
3. Process A starts
4. First Activity starts->
5. Process A starts
Here, you can see that process A is getting started every time First Activity starts. Instead, is there any way I can do something like this?
1. App starts
2. Process A starts
3. First activity starts
4. Second activity starts
5. etc...Process A never starts again, until the app is opened again
Now, is there any way that I can have process A not start again, even if the app is gone? For example:
1. App starts
2. Process A starts
3. First activity starts
4. Second activity starts
5. User presses home menu
6. App starts again, but since user never closed app in multitasking, `process A never started`
Thanks for your expert help in how I can achieve this,
Ruchir