当前位置: 首页>>代码示例>>Java>>正文


Java BlockCanary类代码示例

本文整理汇总了Java中com.github.moduth.blockcanary.BlockCanary的典型用法代码示例。如果您正苦于以下问题:Java BlockCanary类的具体用法?Java BlockCanary怎么用?Java BlockCanary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BlockCanary类属于com.github.moduth.blockcanary包,在下文中一共展示了BlockCanary类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initApplication

import com.github.moduth.blockcanary.BlockCanary; //导入依赖的package包/类
private void initApplication() {
        //初始化日志
        Logger.init(getPackageName()).hideThreadInfo();

        //初始化错误收集
//        CrashHandler.init(new CrashHandler(getApplicationContext()));
        initBugly();

        //初始化内存泄漏检测
        LeakCanary.install(App.getInstance());

        //初始化过度绘制检测
        BlockCanary.install(getApplicationContext(), new AppBlockCanaryContext()).start();

        //初始化tbs x5 webview
        QbSdk.allowThirdPartyAppDownload(true);
        QbSdk.initX5Environment(getApplicationContext(), QbSdk.WebviewInitType.FIRSTUSE_AND_PRELOAD, new QbSdk.PreInitCallback() {
            @Override
            public void onCoreInitFinished() {
            }

            @Override
            public void onViewInitFinished(boolean b) {
            }
        });
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:InitializeService.java

示例2: onCreate

import com.github.moduth.blockcanary.BlockCanary; //导入依赖的package包/类
@Override
    public void onCreate() {
        super.onCreate();
        mAppContext = getApplicationContext();
        // 初始化 retrofit
//        CrashHandler.init(new CrashHandler(getApplicationContext()));

        /**
         * 如果存在SD卡则将缓存写入SD卡,否则写入手机内存
         */

        if (getApplicationContext().getExternalCacheDir() != null && ExistSDCard()) {
            cacheDir = getApplicationContext().getExternalCacheDir().getAbsolutePath();

        } else {
            cacheDir = getApplicationContext().getCacheDir().toString();
        }
        PreferenceManager.initPreferences(this);
        LeakCanary.install(this);
        BlockCanary.install(this, new AppBlockCanaryContext()).start();
    }
 
开发者ID:hljwang3874149,项目名称:ElephantReader,代码行数:22,代码来源:BaseApplication.java

示例3: onCreate

import com.github.moduth.blockcanary.BlockCanary; //导入依赖的package包/类
@Override
    public void onCreate() {
        super.onCreate();

        appContext = this;

        if (LeakCanary.isInAnalyzerProcess(this)) {
            return;
        }
        enabledStrictMode();
        LeakCanary.install(this);

        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyDeath().build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyDeath().build());

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

//        TwinklingRefreshLayout.setDefaultHeader(SinaRefreshView.class.getName());
//        TwinklingRefreshLayout.setDefaultFooter(BallPulseView.class.getName());
    }
 
开发者ID:lcodecorex,项目名称:TwinklingRefreshLayout,代码行数:21,代码来源:TkApplication.java

示例4: onCreate

import com.github.moduth.blockcanary.BlockCanary; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    sAppContext = getApplicationContext();
    CrashHandler.init(new CrashHandler(getApplicationContext()));
    if (!BuildConfig.DEBUG) {
        FIR.init(this);
    } else {
        Watcher.getInstance().start(this);
        Stetho.initializeWithDefaults(this);
    }
    BlockCanary.install(this, new AppBlockCanaryContext()).start();
    LeakCanary.install(this);
    RxJavaPlugins.setErrorHandler(throwable -> {
        if (throwable != null) {
            PLog.e(throwable.toString());
        } else {
            PLog.e("call onError but exception is null");
        }
    });
    /*
     * 如果存在SD卡则将缓存写入SD卡,否则写入手机内存
     */
    if (getApplicationContext().getExternalCacheDir() != null && ExistSDCard()) {
        sCacheDir = getApplicationContext().getExternalCacheDir().toString();
    } else {
        sCacheDir = getApplicationContext().getCacheDir().toString();
    }
}
 
开发者ID:xcc3641,项目名称:SeeWeather,代码行数:30,代码来源:BaseApplication.java

示例5: init

import com.github.moduth.blockcanary.BlockCanary; //导入依赖的package包/类
void init(Context context) {
    // AndroidDevMetrics
    AndroidDevMetrics.initWith(context);

    // Stetho
    Stetho.initialize(Stetho.newInitializerBuilder(context)
            .enableDumpapp(Stetho.defaultDumperPluginsProvider(context))
            .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(context))
            .build());

    // StrictMode
    StrictModeNotifier.install(context);
    new Handler().post(() -> {
        final StrictMode.ThreadPolicy threadPolicy =
                new StrictMode.ThreadPolicy.Builder().detectAll()
                        .permitDiskReads()
                        .permitDiskWrites()
                        .penaltyLog() // Must!
                        .build();
        StrictMode.setThreadPolicy(threadPolicy);

        final StrictMode.VmPolicy vmPolicy =
                new StrictMode.VmPolicy.Builder()
                        .detectAll()
                        .penaltyLog() // Must!
                        .build();
        StrictMode.setVmPolicy(vmPolicy);
    });

    // LeakCanary
    LeakCanary.install((App) context.getApplicationContext());

    //Timber
    Timber.plant(new Timber.DebugTree());

    //BlockCanary
    BlockCanary.install(context, new BlockCanaryContext()).start();
}
 
开发者ID:netguru,项目名称:inbbbox-android,代码行数:39,代码来源:DebugMetricsHelper.java

示例6: onCreate

import com.github.moduth.blockcanary.BlockCanary; //导入依赖的package包/类
@Override
    public void onCreate() {
        super.onCreate();
        if (null == demoAppContext) {
            demoAppContext = getApplicationContext();
        }
//        queues = Volley.newRequestQueue(demoAppContext);
//        CrashHandler crashHandler = CrashHandler.getInstance();
//        crashHandler.init(getApplicationContext());
//        crashHandler.initActivityContainer(container);
        container = new ArrayList<>(5);

        if (Constants.IS_OPEN_UI_BLOCK_CANARY) {
            sContext = this;
            BlockCanary.install(this, new DemoBlockCanaryContext()).start();
        }
        if (Constants.IS_OPEN_LEAK_CANARY) {
            refWatcher = initLeakCanary();
        }

        if (Constants.IS_OPEN_STETHO) {
            // 查看 dumpapp 信息
//            Stetho.initialize(Stetho.newInitializerBuilder(this).enableDumpapp(new DumperPluginsProvider() {
//                @Override
//                public Iterable<DumperPlugin> get() {
//                    return new Stetho.DefaultDumperPluginsBuilder(DemoApplication.this).provide(new HelloWorldDumperPlugin()).provide(new APODDumperPlugin(DemoApplication.this.getContentResolver())).finish();
//                }
//            }).enableWebKitInspector(new ExtInspectorModulesProvider(DemoApplication.this)).build());
            // 调用 JS
            Stetho.initialize(Stetho.newInitializerBuilder(DemoApplication.this).enableWebKitInspector(new InspectorModulesProvider() {
                @Override
                public Iterable<ChromeDevtoolsDomain> get() {
                    return new Stetho.DefaultInspectorModulesBuilder(DemoApplication.this).runtimeRepl(new JsRuntimeReplFactoryBuilder(DemoApplication.this)
                            // Pass to JavaScript: var foo = "bar";
                            .addVariable("foo", "bar").build()).finish();
                }
            }).build());
        }

    }
 
开发者ID:BruceHurrican,项目名称:asstudydemo,代码行数:41,代码来源:DemoApplication.java

示例7: onCreate

import com.github.moduth.blockcanary.BlockCanary; //导入依赖的package包/类
public void onCreate() {

        if (!app.getApplicationInfo().packageName.equals(SysUtils.getCurProcessName(app)))
            return;
        appCreateCount = 0;

        //  创建或更新数据库
        DBConfig.init(app);

        // Log 配置
        Log.init().logLevel(BuildConfig.DEBUG ? LogLevel.FULL : LogLevel.NONE);

        // 配置: ANR异常捕获 内存泄露捕获
        if (!LeakCanary.isInAnalyzerProcess(app)) {
            BlockCanary.install(app, new AppBlockCanaryContext()).start();
            LeakCanary.install(app);
        }

        // init  CrashReport
        CrashReportConfig.init(app);
        //  Device ID
        AppConfig.setDeviceId(app);
        //  渠道号
        AppConfig.setChannel(app);


        // 生命周期
        app.registerActivityLifecycleCallbacks(this);


        // 配置网络请求
        HttpConfig.init(app);


        if (BuildConfig.DEBUG) {
            SysUtils.getPhoneIp();
        }
        // 屏幕宽高
        ScreenUtils.init(app);

    }
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:42,代码来源:AppDelegate.java

示例8: init

import com.github.moduth.blockcanary.BlockCanary; //导入依赖的package包/类
@Override
public void init(Context context) {
    BlockCanary.install(context, new AppBlockCanaryContext()).start();
}
 
开发者ID:fendoudebb,项目名称:PlayAndroid,代码行数:5,代码来源:DebugBlockCanaryHelper.java

示例9: onCreate

import com.github.moduth.blockcanary.BlockCanary; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    // 避免多进程初始化多次
    sInstance = this;
    String processName = AppUtils.getProcessName();
    LogUtils.d("processName:" + processName);
    if (TextUtils.equals(processName, sMainProcessName)) {
        LogUtils.e(sMainProcessName.concat(" process init..."));
        registerActivityLifecycleCallbacks(this);
        // 开始调试侦查器
        if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
            StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                    .detectDiskReads()
                    .detectDiskWrites()
                    .detectNetwork()
                    .penaltyLog()
                    .build());
            StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
                    .detectLeakedSqlLiteObjects()
                    .penaltyLog()
                    .penaltyDeath()
                    .build());
        }
        if (BuildConfig.DEBUG) {
            mRefWatcher = LeakCanary.install(this);
        }
        if (BuildConfig.DEBUG) {
            BlockCanary.install(this, new AppBlockCanaryContext()).start();
        }
        mGlide = GlideManager.getInstance(getApplicationContext());
        // chrome://inspect 调试
        if (BuildConfig.DEBUG) {
            Stetho.initialize(Stetho.newInitializerBuilder(this)
                    .enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
                    .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this))
                    .build());
        }
        mAppCrashHandler = new AppCrashHandler(this, this);
        Thread.setDefaultUncaughtExceptionHandler(mAppCrashHandler);
    } else {
        LogUtils.d(processName.concat("process init..."));
    }
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:45,代码来源:AndroidApplication.java

示例10: onCreate

import com.github.moduth.blockcanary.BlockCanary; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    BlockCanary.install(this, new AppBlockCanaryContext()).start();
}
 
开发者ID:devilWwj,项目名称:Android-Tech,代码行数:6,代码来源:DemoApplication.java

示例11: onCreate

import com.github.moduth.blockcanary.BlockCanary; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    sContext = this;
    BlockCanary.install(this, new AppContext()).start();
}
 
开发者ID:markzhai,项目名称:AndroidPerformanceMonitor,代码行数:7,代码来源:DemoApplication.java

示例12: onCreate

import com.github.moduth.blockcanary.BlockCanary; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    // Do it on main process
    BlockCanary.install(this, new AppBlockCanaryContext()).start();
}
 
开发者ID:TUBB,项目名称:CalendarSelector,代码行数:7,代码来源:TestApplication.java


注:本文中的com.github.moduth.blockcanary.BlockCanary类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。