In order to call some method just once in the app’s lifecycle, not each time
the app is launched, where should I place such method?
In onCreate() or somewhere else?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can add it to
onCreate()and only call the method if it hasn’t been initialized/called previously.If you are looking to call this method only once ever, I would take a look at most answers in here recommending using
Preferences. But if you are talking about once per time the app is brought to life, this should be achieved inonCreate(), as this should only be called once the app is initialized and started.