Detect First Run

后端 未结 4 685
我在风中等你
我在风中等你 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:05

    The fact is that savedInstanceState holds persistent data across activities. As such if you restart the app, savedInstanceState will be null across runs. You should either use a Preference or some data base entry to keep track of your first run. I myself use a SharedPreference for this purpose.

提交回复
热议问题