Application Oncreate()初始化的时候 初始化了三遍 导致重复初始化资源,导致浪费

StringappName = getCurrentProcessName(sAppContext);

        if (!TextUtils.equals(appName,sAppContext.getPackageName())) {

            return;

        }

StringgetCurrentProcessName(Context context) {

        int pid = android.os.Process.myPid();

        ActivityManager mActivityManager =(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

        for (ActivityManager.RunningAppProcessInfoappProcess : mActivityManager.getRunningAppProcesses()) {

            if (appProcess.pid == pid) {

                return appProcess.processName;

            }

        }

        return "";

    }

你可能感兴趣的:(Android)