Java Code Examples for com.tencent.mmkv.MMKV#initialize()

The following examples show how to use com.tencent.mmkv.MMKV#initialize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseApplication.java    From DevUtils with Apache License 2.0 6 votes vote down vote up
/**
     * 初始化其他 lib
     */
    private void initOthers() {
        // 初始化 MMKV
        String rootDir = MMKV.initialize(this);
        DevLogger.d("MMKV rootDir: " + rootDir);

        // https://github.com/JessYanCoding/AndroidAutoSize/blob/master/demo-subunits/src/main/java/me/jessyan/autosize/demo/subunits/BaseApplication.java
        // 可不调用, 默认开启 DP 转换
        AutoSizeConfig.getInstance().getUnitsManager()
                .setSupportDP(true);

        // 初始化 GreenDao
        GreenManager.init(this);

//        // 初始化 OkGo
//        OkGoUtils.initOkGo(this);
    }
 
Example 2
Source File: App.java    From 12306XposedPlugin with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    MMKV.initialize(this);
    registerDatabaseManager();
    startService(new Intent(this, ShareService.class));
}
 
Example 3
Source File: MyApplication.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
@Override
    @DebugLog
    public void onCreate() {
        super.onCreate();

        Debug.startMethodTracing("sample");

        MultiDex.install(this);
        Stetho.initializeWithDefaults(this);

        if (BuildConfig.DEBUG) {
            ARouter.openLog();
            ARouter.openDebug();
        }

        ARouter.init(this);
        Fresco.initialize(this);
        String dir = MMKV.initialize(this);
        Log.e("application", "onCreate: mmkv.dir==" + dir);
        WebView.setWebContentsDebuggingEnabled(true);


        DoraemonKit.disableUpload();
        DoraemonKit.install(this);
//        DoraemonKit.hide();
        logLifeCycleCallBacks();

        Debug.stopMethodTracing();
    }
 
Example 4
Source File: PerformanceApp.java    From android-performance with MIT License 4 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();

        MMKV.initialize(PerformanceApp.this);
        MMKV.defaultMMKV().encode("times",100);

        int times = MMKV.defaultMMKV().decodeInt("times");


        LaunchTimer.startRecord();
        mApplication = this;

        TaskDispatcher.init(PerformanceApp.this);

        TaskDispatcher dispatcher = TaskDispatcher.createInstance();

        dispatcher.addTask(new InitAMapTask())
                .addTask(new InitStethoTask())
                .addTask(new InitWeexTask())
                .addTask(new InitBuglyTask())
                .addTask(new InitFrescoTask())
                .addTask(new InitJPushTask())
                .addTask(new InitUmengTask())
                .addTask(new GetDeviceIdTask())
                .start();

        dispatcher.await();

        LaunchTimer.endRecord();

        DexposedBridge.hookAllConstructors(ImageView.class, new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                super.afterHookedMethod(param);
                DexposedBridge.findAndHookMethod(ImageView.class, "setImageBitmap", Bitmap.class, new ImageHook());
            }
        });


//        try {
//            DexposedBridge.findAndHookMethod(Class.forName("android.os.BinderProxy"), "transact",
//                    int.class, Parcel.class, Parcel.class, int.class, new XC_MethodHook() {
//                        @Override
//                        protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
//                            LogUtils.i( "BinderProxy beforeHookedMethod " + param.thisObjecObservablet.getClass().getSimpleName()
//                                    + "\n" + Log.getStackTraceString(new Throwable()));
//                            super.beforeHookedMethod(param);
//                        }
//                    });
//        } catch (ClassNotFoundException e) {
//            e.printStackTrace();
//        }

//        BlockCanary.install(this, new AppBlockCanaryContext()).start();

        initStrictMode();

//        new ANRWatchDog().start();
    }
 
Example 5
Source File: BenchmarkManager.java    From FastSharedPreferences with Apache License 2.0 4 votes vote down vote up
public void init(Context context) {
    this.context = context.getApplicationContext();
    MMKV.initialize(this.context);
}
 
Example 6
Source File: MMKVUtils.java    From TemplateAppProject with Apache License 2.0 2 votes vote down vote up
/**
 * 初始化
 *
 * @param context
 */
public static void init(Context context) {
    MMKV.initialize(context.getApplicationContext());
    sMMKV = MMKV.defaultMMKV();
}