Java Code Examples for com.squareup.leakcanary.LeakCanary#install()

The following examples show how to use com.squareup.leakcanary.LeakCanary#install() . 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: NavigationApplication.java    From graphhopper-navigation-android with MIT License 8 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();

  // Leak canary
  if (LeakCanary.isInAnalyzerProcess(this)) {
    return;
  }
  LeakCanary.install(this);

  if (BuildConfig.DEBUG) {
    Timber.plant(new Timber.DebugTree());
  }

  // Set access token
  String mapboxAccessToken = Utils.getMapboxAccessToken(getApplicationContext());
  if (TextUtils.isEmpty(mapboxAccessToken) || mapboxAccessToken.equals(DEFAULT_MAPBOX_ACCESS_TOKEN)) {
    Log.w(LOG_TAG, "Warning: access token isn't set.");
  }

  Mapbox.getInstance(getApplicationContext(), mapboxAccessToken);
}
 
Example 2
Source File: SampleApplication.java    From RIBs with Apache License 2.0 6 votes vote down vote up
/**
 * Install leak canary for both activities and RIBs.
 */
private void installLeakCanary() {
  final RefWatcher refWatcher = LeakCanary
          .refWatcher(this)
          .watchDelay(2, TimeUnit.SECONDS)
          .buildAndInstall();
  LeakCanary.install(this);
  RibRefWatcher.getInstance().setReferenceWatcher(new RibRefWatcher.ReferenceWatcher() {
    @Override
    public void watch(Object object) {
      refWatcher.watch(object);
    }

    @Override
    public void logBreadcrumb(String eventType, String data, String parent) {
      // Ignore for now. Useful for collecting production analytics.
    }
  });
  RibRefWatcher.getInstance().enableLeakCanary();
}
 
Example 3
Source File: MovieBrowserApplication.java    From Android-App-Architecture-MVVM-Databinding with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (BuildConfig.DEBUG) {
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                .detectAll()
                .penaltyLog()
                .build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
                .detectAll()
                .penaltyLog()
                .build());

        LeakCanary.install(this);
        // Uncomment to debug using Stetho
        // com.facebook.stetho.Stetho.initializeWithDefaults(this);
    }

    init();
}
 
Example 4
Source File: App.java    From AndroidScreenAdaptation 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);
    ScreenAdapterTools.init(this);

}
 
Example 5
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 6
Source File: DebugApp.java    From Synapse with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    if (!LeakCanary.isInAnalyzerProcess(this)) {
        LeakCanary.install(this);
    }
}
 
Example 7
Source File: TavernaApplication.java    From incubator-taverna-mobile with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    FlowManager.init(new FlowConfig.Builder(this).build());
    if (BuildConfig.DEBUG) {
        Stetho.initializeWithDefaults(this);
    }

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

}
 
Example 8
Source File: LauncherApplication.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    sLauncherStats = LauncherStats.getInstance(this);
    AggregationIntentService.scheduleService(this);
    LeakCanary.install(this);
}
 
Example 9
Source File: App.java    From QuickLyric with 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 10
Source File: ClonedApplication.java    From GooglePlayCloned 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...
}
 
Example 11
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 12
Source File: MainActivity.java    From PLDroidRTCStreaming with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    LeakCanary.install(getApplication());
    RTCMediaStreamingManager.init(getApplicationContext(), RTCServerRegion.RTC_CN_SERVER);

    TextView versionInfoTextView = (TextView) findViewById(R.id.version_info_textview);
    String info = "版本号:" + getVersionDescription() + ",编译时间:" + getBuildTimeDescription();
    versionInfoTextView.setText(info);
}
 
Example 13
Source File: JDApplication.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    StrictModeUtil.init();
    super.onCreate();
    refWatcher = LeakCanary.install(this);
    mContext = this;
    ImageLoadProxy.initImageLoader(this);

    if (BuildConfig.DEBUG) {
        Logger.init().hideThreadInfo().setMethodCount(1).setLogLevel(LogLevel.FULL);
    }
}
 
Example 14
Source File: MainApplication.java    From ApkTrack with GNU General Public License v3.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);
}
 
Example 15
Source File: App.java    From WanAndroid with Apache License 2.0 4 votes vote down vote up
private void initLeakCanary() {
    if (!LeakCanary.isInAnalyzerProcess(this))
        LeakCanary.install(this);
}
 
Example 16
Source File: MyApplication.java    From android-samples with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    refWatcher = LeakCanary.install(this);
}
 
Example 17
Source File: MyApplication.java    From IDCardCamera with Apache License 2.0 4 votes vote down vote up
private void initLeakCanary() {
    if (LeakCanary.isInAnalyzerProcess(this)) {
        return;
    }
    LeakCanary.install(this);
}
 
Example 18
Source File: HawkularApplication.java    From hawkular-android-client with Apache License 2.0 4 votes vote down vote up
private void setUpLeakCanary() {
    if (LeakCanary.isInAnalyzerProcess(this)) {
        return;
    }
    refWatcher = LeakCanary.install(this);
}
 
Example 19
Source File: WooCommerce.java    From Woocommerce-Android-Client with MIT License 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    LeakCanary.install(this);

}
 
Example 20
Source File: AppApplication.java    From XKnife-Android with Apache License 2.0 2 votes vote down vote up
/**
 * Init leak canary.
 * 返回一个预定义的 RefWatcher,用于自动监控调用 Activity.onDestroy() 之后泄露的 activity
 */
private void initLeakCanary() {
    refWatcher = LeakCanary.install(this);
}