How can I execute something just once per application start?

前端 未结 10 1440
感情败类
感情败类 2020-11-28 06:45

I\'d like to implement an update checker in an application, and I obviously only need this to show up once when you start the application. If I do the call in the onCr

10条回答
  •  长情又很酷
    2020-11-28 07:11

    Use SharedPreference for this-

    1. If you are not restarting your launcher activity again once your app is active then in that case you case use it.

    2. Use this in a Splash screen if you are implementing it in the app.

    3. If you are not using any splash screen then you need to create a activity with no view set and on it's oncreate call you can do start updation and start your main activity.

    you can use counter value or boolean for this.

    Here is SharedPreference doc:

    http://developer.android.com/reference/android/content/SharedPreferences.html

提交回复
热议问题