Determine if Android app is being used for the first time

前端 未结 16 1341
攒了一身酷
攒了一身酷 2020-11-22 12:47

I am currently developing an android app. I need to do something when the app is launched for the first time, i.e. the code only runs on the first time the program is launch

16条回答
  •  我在风中等你
    2020-11-22 13:42

    There is support for just this in the support library revision 23.3.0 (in the v4 which means compability back to Android 1.6).

    In your Launcher activity, first call:

    AppLaunchChecker.onActivityCreate(activity);
    

    Then call:

    AppLaunchChecker.hasStartedFromLauncher(activity);
    

    Which will return if this was the first time the app was launched.

提交回复
热议问题