Detect First Run

后端 未结 4 694
我在风中等你
我在风中等你 2020-12-18 16:31

I am trying to detect if my app has been run before, by using this code:

(This is in my default Android activity)

@Override
public void onCreate(Bund         


        
4条回答
  •  醉话见心
    2020-12-18 17:31

    savedInstanceState will be null if the app is not already loaded in memory. If you want to detect whether the app has run for the very first time, you have to apply different technique, such as using sharedPrefs / DB to store a property for the first run.

    i.e. Check sharedPrefs for property "firstRun"

    if exists, then it is not a first run

    else it is the first run

    set the firstRun property to true

提交回复
热议问题