1. Judge the first startup of the APP

2.APP starts judging today

Serving:

FirstStartUtils.java

    /** * This method is called for the first time, and if it is called for the first time, even if it is called for the first time, the second call will become a non-first call. If it is called for the first time, the second call will become a non-first call. If it is called for the first time, the second call will become a non-first call@param context
     * @return* /
    public static boolean isFirstStart(Context context) {
        SharedPreferences preferences = context.getSharedPreferences(
                "NB_FIRST_START".0);
        Boolean isFirst = preferences.getBoolean("FIRST_START".true);
        if (isFirst) {/ / for the first time
            preferences.edit().putBoolean("FIRST_START".false).commit();
            return true;
        } else {
            return false; }}/** * Start APP * for the first time today@param context
     * @return* /
    public static boolean isTodayFirstStartApp(Context context) {
        try {
            SharedPreferences preferences = context.getSharedPreferences("NB_TODAY_FIRST_START_APP", context.MODE_PRIVATE);
            String svaeTime = preferences.getString("startAppTime"."2021-07-26");
            String todayTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date());

            if(! TextUtils.isEmpty(todayTime) && ! TextUtils.isEmpty(svaeTime)) {if(! svaeTime.equals(todayTime)) { preferences.edit().putString("startAppTime", todayTime).commit();
                    return true; }}}catch (Exception e){
            log(TAG, "Is it the first time to start the APP today?+e.toString());
            return true;
        }
        return  false;

    }

Copy the code