com.squareup.leakcanary.LeakCanary Java Examples

The following examples show how to use com.squareup.leakcanary.LeakCanary. 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: Aadira.java    From Woocommerce-Android-Client with MIT License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    WCBuilder builder = new WCBuilder();
    builder.setIsHttps(false);
    builder.setBaseUrl("www.aadira.com");
    builder.setSigning_method(SigningMethod.HMACSHA1);
    builder.setWc_key("ck_b1c74943c7ad59d34ee8477a210d12cfaff14406");
    builder.setWc_secret("cs_c9233d13c31eb3117b3cfdcc53e4ddc358e3545d");
    WooCommerce.getInstance().initialize(builder);

    LeakCanary.install(this);

    System.out.println(WooCommerce.getInstance().toString());
}
 
Example #2
Source File: AppHeap.java    From AcDisplay with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Must be called at {@link android.app.Application#onCreate()}
 */
public void init(@NonNull Application application, @NonNull IConfiguration configuration) {
    mRefWatcher = LeakCanary.install(application);

    mCheckoutInternal = new CheckoutInternal(application, Products.create()
            .add(ProductTypes.IN_APP, configuration.getBilling().getProducts())
            .add(ProductTypes.SUBSCRIPTION, Collections.singletonList("")));
    mConfiguration = configuration;
    mApplication = application;

    // Setup log
    /*
    if (DEBUG) {
        Timber.plant(new Timber.DebugTree());
    } else {
        Timber.plant(new ReleaseTree());
    }
    */
    Timber.plant(new ReleaseTree());

    TypefaceHelper.initialize(application);
    RuntimePermissions.getInstance().load(application);
}
 
Example #3
Source File: App.java    From UIWidget with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    sContext = this;
    CrashReport.initCrashReport(getApplicationContext());
    String appChannel = (String) SPUtil.get(getApplicationContext(), SPConstant.SP_KEY_APP_CHANNEL, "");
    Log.i("appChannel", "appChannel0:" + appChannel);
    if (TextUtils.isEmpty(appChannel)) {
        appChannel = CrashReport.getAppChannel();
        Log.i("appChannel", "appChannel1:" + appChannel);
        SPUtil.put(getApplicationContext(), SPConstant.SP_KEY_APP_CHANNEL, appChannel);
    } else {
        CrashReport.setAppChannel(getApplicationContext(), appChannel);
    }
    Log.i("appChannel", "appChannel2:" + appChannel);
    if (BuildConfig.DEBUG) {
        CrashReport.closeBugly();
    }
    if (LeakCanary.isInAnalyzerProcess(this)) {
        // This process is dedicated to LeakCanary for heap analysis.
        // You should not init your app in this process.
        return;
    }
    LeakCanary.install(this);
    registerActivityLifecycleCallbacks(this);
}
 
Example #4
Source File: App.java    From mvp-helpers with MIT License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
        IMMLeaks.fixAllPossiblyFocusedViewLeaks(this);
    }

    UserManagerLeaks.fixLeakInGetMethod(this);

    if (BuildConfig.DEBUG) {
        if (LeakCanary.isInAnalyzerProcess(this)) {
            // This process is dedicated to LeakCanary for heap analysis.
            // You should not init your app in this process.
            return;
        }

        LeakCanary.install(this);
    }
}
 
Example #5
Source File: TestModuleApplication.java    From JD-Test with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (LeakCanary.isInAnalyzerProcess(this)) {
        return;
    }
    if(CommonConfig.DEBUG){
        LeakCanary.install(this);
        ARouter.openLog();     // 打印日志
        ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
    }

    ARouter.init(this);
    //CrashReport.initCrashReport(getApplicationContext(), "93f0e37549", CommonConfig.DEBUG);
    Fresco.initialize(this);
    GlobalAppComponent.init(this);
}
 
Example #6
Source File: SampleApplication.java    From px-android with MIT License 6 votes vote down vote up
private void initializeLeakCanary() {
    if (LeakCanary.isInAnalyzerProcess(this)) {
        return;
    }
    LeakCanary.install(this);
    Stetho.initializeWithDefaults(this);

    // Create client base, add interceptors
    OkHttpClient.Builder baseClient = HttpClientUtil.createBaseClient(this, 10, 10, 10)
        .addNetworkInterceptor(new StethoInterceptor());

    // customClient: client with TLS protocol setted
    final OkHttpClient customClient = HttpClientUtil.enableTLS12(baseClient)
        .build();

    HttpClientUtil.setCustomClient(customClient);

    Dependencies.getInstance().initialize(getApplicationContext());

    final ESCManagerBehaviour escManagerBehaviour = new FakeEscManagerBehaviourImpl();
    new PXBehaviourConfigurer()
        .with(new MockSecurityBehaviour(escManagerBehaviour))
        .with(escManagerBehaviour)
        .with(FakeLocaleBehaviourImpl.INSTANCE)
        .configure();
}
 
Example #7
Source File: MyApp.java    From RxJava-Android-Samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();

  if (LeakCanary.isInAnalyzerProcess(this)) {
    // This process is dedicated to LeakCanary for heap analysis.
    // You should not init your app in this process.
    return;
  }

  _instance = (MyApp) getApplicationContext();
  _refWatcher = LeakCanary.install(this);

  // for better RxJava debugging
  //RxJavaHooks.enableAssemblyTracking();

  // Initialize Volley
  MyVolley.init(this);

  Timber.plant(new Timber.DebugTree());
}
 
Example #8
Source File: ReadhubApplicationLike.java    From JReadHub with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    sApp = getApplication();
    sInstance = this;
    appComponent = DaggerAppComponent.builder()
            .appModule(new AppModule(sApp))
            /*.databaseModule(new DatabaseModule())
            .networkModule(new NetworkModule())*/
            .build();
    appComponent.inject(this);
    if (LeakCanary.isInAnalyzerProcess(getApplication())) {
        // This process is dedicated to LeakCanary for heap analysis.
        // You should not init your app in this process.
        return;
    }
    initBugly();

    LeakCanary.install(getApplication());
    AppStatusTracker.init(getApplication());
    AndroidThreeTen.init(getApplication());
    //CrashHandler.getApp().init(getApplicationContext());
}
 
Example #9
Source File: U2020App.java    From u2020 with Apache License 2.0 6 votes vote down vote up
@Override public void onCreate() {
  super.onCreate();
  if (LeakCanary.isInAnalyzerProcess(this)) {
    return;
  }
  AndroidThreeTen.init(this);
  LeakCanary.install(this);

  if (BuildConfig.DEBUG) {
    Timber.plant(new DebugTree());
  } else {
    // TODO Crashlytics.start(this);
    // TODO Timber.plant(new CrashlyticsTree());
  }

  objectGraph = ObjectGraph.create(Modules.list(this));
  objectGraph.inject(this);

  lumberYard.cleanUp();
  Timber.plant(lumberYard.tree());
}
 
Example #10
Source File: AnagoApplication.java    From Anago with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

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

        Stetho.initializeWithDefaults(this);

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

    injector = buildAppComponent();
}
 
Example #11
Source File: PushChatApplication.java    From OPFPush with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    refWatcher = LeakCanary.install(this);

    OPFLog.setEnabled(BuildConfig.DEBUG, true);
    OPFLog.logMethod();

    uuid = UuidGenerator.generateUuid(this);

    OPFLog.i("Generated uuid : %s", uuid);
    final Configuration.Builder configBuilder = new Configuration.Builder()
            .addProviders(
                    new GCMProvider(this, GCM_SENDER_ID),
                    new ADMProvider(this),
                    new NokiaNotificationsProvider(this, NOKIA_SENDER_ID)
            )
            .setSelectSystemPreferred(true)
            .setEventListener(new PushEventListener());

    OPFPush.init(this, configBuilder.build());
    OPFPush.getHelper().register();
}
 
Example #12
Source File: U2020App.java    From u2020-mvp with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    AndroidThreeTen.init(this);
    LeakCanary.install(this);

    if (BuildConfig.DEBUG) {
        Timber.plant(new DebugTree());
    } else {
        // TODO Crashlytics.start(this);
        // TODO Timber.plant(new CrashlyticsTree());
    }

    buildComponentAndInject();

    registerActivityLifecycleCallbacks(activityHierarchyServer);
}
 
Example #13
Source File: MyApplication.java    From AndroidRxJavaSample with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
            .detectDiskReads()
            .detectDiskWrites()
            .detectNetwork()   // or .detectAll() for all detectable problems
            .penaltyLog()
            .build());

    StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
            .detectLeakedSqlLiteObjects()
            .detectLeakedClosableObjects()
            .penaltyLog()
            .penaltyDeath()
            .build());
    super.onCreate();

    LeakCanary.install(this);
}
 
Example #14
Source File: Application.java    From materialistic with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    AppCompatDelegate.setDefaultNightMode(Preferences.Theme.getAutoDayNightMode(this));
    AlgoliaClient.sSortByTime = Preferences.isSortByRecent(this);
    mRefWatcher = LeakCanary.install(this);
    if (BuildConfig.DEBUG) {
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                .detectAll()
                .penaltyFlashScreen()
                .build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
                .detectAll()
                .penaltyLog()
                .build());
    }
    Preferences.migrate(this);
    TYPE_FACE = FontCache.getInstance().get(this, Preferences.Theme.getTypeface(this));
    AppUtils.registerAccountsUpdatedListener(this);
    AdBlocker.init(this, Schedulers.io());
}
 
Example #15
Source File: CommonModule.java    From JD-Test with Apache License 2.0 6 votes vote down vote up
public static void init(Application application){

        if (LeakCanary.isInAnalyzerProcess(application)) {
            return;
        }
        if(BuildConfig.DEBUG){
            LeakCanary.install(application);
            ARouter.openLog();     // 打印日志
            ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
        }

        ARouter.init(application);
        //CrashReport.initCrashReport(getApplicationContext(), "93f0e37549", CommonConfig.DEBUG);
        Fresco.initialize(application);
        GlobalAppComponent.init(application);

        //平行module初始化
        ARouter.getInstance().build("/MainModule/MainModule").navigation();
        ARouter.getInstance().build("/TestModule/TestModule").navigation();
    }
 
Example #16
Source File: App.java    From android-open-framework-analysis with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (LeakCanary.isInAnalyzerProcess(this)) {
        return;
    }
    refWatcher = LeakCanary.install(this);
}
 
Example #17
Source File: ZhihuApplication.java    From RxZhihuPager with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Logger.init(TAG);
    Stetho.initialize(Stetho.newInitializerBuilder(this)
            .enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
            .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this))
            .build());
    LeakCanary.install(this);
    Fresco.initialize(this);
}
 
Example #18
Source File: MainApplication.java    From mapbox-events-android with MIT License 5 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();
  if (LeakCanary.isInAnalyzerProcess(this)) {
    // This process is dedicated to LeakCanary for heap analysis.
    return;
  }
  LeakCanary.install(this);
}
 
Example #19
Source File: MyApplication.java    From EasyPhotos with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (LeakCanary.isInAnalyzerProcess(this)) {
        // This process is dedicated to LeakCanary for heap analysis.
        // You should not init your app in this process.
        return;
    }
    CrashReport.initCrashReport(getApplicationContext(), "4c251b8f40", false);
    LeakCanary.install(this);
}
 
Example #20
Source File: BaseApplication.java    From MarkdownEditors with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    context = getApplicationContext();
    resource = context.getResources();

    if (hasMemoryLeak()) {
        refWatcher = LeakCanary.install(this);//预定义的 RefWatcher,同时也会启用一个 ActivityRefWatcher
    }
    if (hasCrashLog()) {
        CrashWoodpecker.fly().to(this);//崩溃异常捕获
    }

}
 
Example #21
Source File: BaseApplication.java    From POCenter with MIT License 5 votes vote down vote up
/**
 * use LeakCanary to check mey leak
 */
private void initLeakCanary() {
    if (LeakCanary.isInAnalyzerProcess(this)) {
        // This process is dedicated to LeakCanary for heap analysis.
        // You should not init your app in this process.
        return;
    }
    LeakCanary.install(this);
}
 
Example #22
Source File: App.java    From phphub-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Fresco.initialize(this);
    LeakCanary.install(this);
    JPushInterface.setDebugMode(BuildConfig.DEBUG);
    JPushInterface.init(this);

    initializeInjector();
    initializeInjectorApi();

    Iconify.with(new FontAwesomeModule());
}
 
Example #23
Source File: App.java    From mvvm-template with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    sInstance = this;
    initAppComponent();
    setupPreference();
    TypeFaceHelper.generateTypeface(this);
    EmojiManager.load();
    ColorsProvider.load();
    DeviceNameGetter.getInstance().loadDevice();
    refWatcher = LeakCanary.install(this);
}
 
Example #24
Source File: ExampleViewModelApplication.java    From valifi with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
	super.onCreate();
	if (LeakCanary.isInAnalyzerProcess(this)) {
		// This process is dedicated to LeakCanary for heap analysis.
		// You should not init your app in this process.
		return;
	}
	LeakCanary.install(this);

	ValiFi.install(this);
}
 
Example #25
Source File: LeakTool.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
public void setup(Application application) {
  if (LeakCanary.isInAnalyzerProcess(application)) {
    // This process is dedicated to LeakCanary for heap analysis.
    // You should not init your app in this process.
    return;
  }
  refWatcher = LeakCanary.install(application);
}
 
Example #26
Source File: BaseApplication.java    From SeeWeather with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example #27
Source File: AppSubApplication.java    From RunMap with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (LeakCanary.isInAnalyzerProcess(this)) {
        return;
    }
    LeakCanary.install(this);
}
 
Example #28
Source File: AppLifecyclesImpl.java    From MVVMArms with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Application application) {
    if (LeakCanary.isInAnalyzerProcess(application)) {
        // This process is dedicated to LeakCanary for heap analysis.
        // You should not init your app in this process.
        return;
    }
    if (BuildConfig.LOG_DEBUG) {
        /* Timber 是一个日志框架容器,外部使用统一的Api,内部可以动态的切换成任何日志框架(打印策略)进行日志打印
        并且支持添加多个日志框架(打印策略),做到外部调用一次 Api,内部却可以做到同时使用多个策略
        比如添加三个策略,一个打印日志,一个将日志保存本地,一个将日志上传服务器 */
        //Timber初始化
        Timber.plant(new Timber.DebugTree());
        /* 如果你想将框架切换为 Logger 来打印日志,请使用下面的代码,如想切换为其他日志框架请根据下面的方式扩展
        Logger.addLogAdapter(new AndroidLogAdapter());
        Timber.plant(new Timber.DebugTree() {
            @Override
            protected void log(int priority, String tag, String message, Throwable t) {
                Logger.log(priority, tag, message, t);
            }
        }); */
    }

    //LeakCanary内存泄露检查
    RepositoryUtils.INSTANCE.obtainRepositoryComponent(application)
            .extras()
            .put(RefWatcher.class.getName(), BuildConfig.USE_CANARY ? LeakCanary.install(application) : RefWatcher.DISABLED);

    //设置全局Crash监听
    CrashUtils.init(application, RepositoryUtils.INSTANCE.obtainRepositoryComponent(application).cacheFile());

    //扩展 AppManager 的远程遥控功能
    LifecycleUtils.INSTANCE.obtainLifecycleComponent(application).appManager()
            .setHandleListener((appManager, message) -> {
                Timber.d("handleMessage: " + message.what);
                //AppManager.post(message);
                //handle message
            });
}
 
Example #29
Source File: HeroVideoApp.java    From HeroVideo-master with Apache License 2.0 5 votes vote down vote up
private void init() {
    // 初始化主题切换
    ThemeUtils.setSwitchColor(this);
    //初始化Leak内存泄露检测工具
    LeakCanary.install(this);
    //初始化Stetho调试工具
    Stetho.initialize(
            Stetho.newInitializerBuilder(this)
                    .enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
                    .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this))
                    .build());
}
 
Example #30
Source File: App.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    if (LeakCanary.isInAnalyzerProcess(this)) {
        // This process is dedicated to LeakCanary for heap analysis.
        // You should not init your app in this process.
        return;
    }
    LeakCanary.install(this);
    // Normal app init code...



    QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() {

        @Override
        public void onViewInitFinished(boolean arg0) {
            // TODO Auto-generated method stub
            //x5內核初始化完成的回调,为true表示x5内核加载成功,否则表示x5内核加载失败,会自动切换到系统内核。
            Log.d("app", " onViewInitFinished is " + arg0);


        }

        @Override
        public void onCoreInitFinished() {
            // TODO Auto-generated method stub
        }
    };
    //x5内核初始化接口
    QbSdk.initX5Environment(getApplicationContext(),  cb);
}