本文整理汇总了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) {
}
});
}
示例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();
}
示例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());
}
示例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();
}
}
示例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();
}
示例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());
}
}
示例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);
}
示例8: init
import com.github.moduth.blockcanary.BlockCanary; //导入依赖的package包/类
@Override
public void init(Context context) {
BlockCanary.install(context, new AppBlockCanaryContext()).start();
}
示例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..."));
}
}
示例10: onCreate
import com.github.moduth.blockcanary.BlockCanary; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
BlockCanary.install(this, new AppBlockCanaryContext()).start();
}
示例11: onCreate
import com.github.moduth.blockcanary.BlockCanary; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
sContext = this;
BlockCanary.install(this, new AppContext()).start();
}
示例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();
}