Java Code Examples for com.squareup.leakcanary.LeakCanary

The following examples show how to use com.squareup.leakcanary.LeakCanary. These examples are extracted from open source projects. 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 Project: px-android   Source File: SampleApplication.java    License: 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 2
Source Project: RxJava-Android-Samples   Source File: MyApp.java    License: 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 3
@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 4
Source Project: Anago   Source File: AnagoApplication.java    License: 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 5
Source Project: materialistic   Source File: Application.java    License: 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 6
Source Project: Woocommerce-Android-Client   Source File: Aadira.java    License: 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 7
Source Project: u2020-mvp   Source File: U2020App.java    License: 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 8
Source Project: OPFPush   Source File: PushChatApplication.java    License: 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 9
Source Project: u2020   Source File: U2020App.java    License: 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 Project: AndroidRxJavaSample   Source File: MyApplication.java    License: 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 11
Source Project: JD-Test   Source File: CommonModule.java    License: 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 12
Source Project: JD-Test   Source File: TestModuleApplication.java    License: 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 13
Source Project: mvp-helpers   Source File: App.java    License: 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 14
Source Project: AcDisplay   Source File: AppHeap.java    License: 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 15
Source Project: UIWidget   Source File: App.java    License: 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 16
Source Project: EasyPhotos   Source File: MyApplication.java    License: 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 17
Source Project: colorpicker   Source File: App.java    License: 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 18
Source Project: Gloading   Source File: MyApplication.java    License: 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);
    //Init the default loading status view for global usage wrap a
    //      customer Adapter implementation
    Gloading.debug(BuildConfig.DEBUG);
    Gloading.initDefault(new GlobalAdapter());
}
 
Example 19
Source Project: EasySettings   Source File: MyApplication.java    License: 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 20
Source Project: CameraCompat   Source File: DemoApplication.java    License: MIT License 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    if (LeakCanary.isInAnalyzerProcess(this)) {
        return;
    }
    LeakCanary.install(this);
}
 
Example 21
Source Project: ZfsoftCampusAssit   Source File: ZfsoftCampusAsstApp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Log.d(tag,"CampusAsstApp is initializing...");
    PreferenceUtil.init(getApplicationContext());

    LeakCanary.install(this);
    Bmob.initialize(this, Config.BMOB_APP_ID);
}
 
Example 22
Source Project: ShareLoginPayUtil   Source File: App.java    License: Apache License 2.0 5 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();
//        Fabric.with(this, new Crashlytics());
        if (LeakCanary.isInAnalyzerProcess(this)) {
            return;
        }
        LeakCanary.install(this);
    }
 
Example 23
Source Project: Kalle   Source File: App.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (_instance == null) {
        LeakCanary.install(this);
        _instance = this;

        Logger.setEnable(BuildConfig.DEBUG);
        kalle();
        album();
    }
}
 
Example 24
Source Project: power-adapters   Source File: Application.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    RxJavaPlugins.setErrorHandler(e -> Log.e(TAG, "RxJava error", e));
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    LeakCanary.install(this);
}
 
Example 25
Source Project: 920-text-editor-v2   Source File: MainApp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
    protected void installMonitor() {
        if (LeakCanary.isInAnalyzerProcess(this)) {
            // This process is dedicated to LeakCanary for heap analysis.
            // You should not init your app in this process.
            return;
        }
        refWatcher = LeakCanary.install(this);
//        if(!BlockCanaryEx.isInSamplerProcess(this)) {
//            BlockCanaryEx.install(new Config(this));
//        }
    }
 
Example 26
Source Project: QuickLyric   Source File: App.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    super.onCreate();
    refWatcher = LeakCanary.install(this);
    registerActivityLifecycleCallbacks(this);
}
 
Example 27
Source Project: AndroidQuick   Source File: MyApplication.java    License: 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.
        // You should not init your app in this process.
        return;
    }
    LeakCanary.install(this);
    //get application
    if (INSTANCE == null) {
        INSTANCE = this;
    }
    //log switcher
    LogUtil.setLogOn(true);
    //lifecyclecallback
    lifecycleCallback = new AQActivityLifecycleCallbacks();
    registerActivityLifecycleCallbacks(lifecycleCallback);
    //init ToastUtil
    ToastUtil.register(this);
    //init SpUtil
    SpUtil.init(this);
    //init greendao
    DBManager.getInstance().init(getApplicationContext());
    //init immersion

    //init stetho
    Stetho.initializeWithDefaults(this);
    //init crashhandler
    CrashHandler.getInstance().init(this);
    //init tinylog
    TinyLog.config().setEnable(true).apply();
    //init tag
    SearchManager.getInstance().init();
}
 
Example 28
Source Project: BottomNavigationViewEx   Source File: BaseApplication.java    License: 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 29
Source Project: Hands-Chopping   Source File: AppLifecyclesImpl.java    License: 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;
    }
    //使用 RetrofitUrlManager 切换 BaseUrl
    //RetrofitUrlManager.getInstance().putDomain(STEAM_DOMAIN_NAME, STEAM_DOMAIN);
    //当所有模块集成到宿主 App 时, 在 App 中已经执行了以下代码
    if (BuildConfig.IS_BUILD_MODULE) {
        //leakCanary内存泄露检查
        ArmsUtils.obtainAppComponentFromContext(application).extras().put(RefWatcher.class.getName(), BuildConfig.USE_CANARY ? LeakCanary.install(application) : RefWatcher.DISABLED);
    }
}
 
Example 30
Source Project: ByWebView   Source File: App.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (LeakCanary.isInAnalyzerProcess(this)) {
        return;
    }
    LeakCanary.install(this);
    app = this;
    initX5();
}