redrom
redrom

Reputation: 11642

Android: How to Force reload activity if came from background?

I need to force reload activity if something came from background. Meaning, it is already running and is called back from the list of active apps or is tapped on her icon.

I would like to ask what is best practice for this? Should I call onCreate again in onResume event or something else?

Thanks for any help.

Upvotes: 0

Views: 1333

Answers (1)

2Dee
2Dee

Reputation: 8627

Move your code that you want to run every time your Activity comes to the foreground from onCreate to onResume. You don't have to worry about the code running the first time the Activity is launched because onResume is always called after onCreate. This diagram of the Activity lifecycle could help you understand this :

lifecycle diagram

Upvotes: 2

Related Questions