Skip to content

Commit

Permalink
Add more demo code
Browse files Browse the repository at this point in the history
  • Loading branch information
AndroidInternal committed Aug 10, 2020
1 parent 8164b58 commit 03c1afa
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions koom-demo/src/main/java/com/kwai/koom/demo/KOOMApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import android.app.Application;

import com.kwai.koom.javaoom.KOOM;
import com.kwai.koom.javaoom.common.KConfig;
import com.kwai.koom.javaoom.common.KLog;

/**
* Copyright 2020 Kwai, Inc. All rights reserved.
Expand Down Expand Up @@ -47,4 +49,39 @@ public void listenReportGenerateStatus() {
});
}

//Example of how to set custom config.
public void customConfig() {
KConfig kConfig = new KConfig.KConfigBuilder()
.heapRatio(85.0f) //heap occupied ration in percent, 85.0f means use 85% memory of max heap
.rootDir(this.getCacheDir().getAbsolutePath()) //root dir stores report and hprof files
.heapOverTimes(3) //heap max times of over heap's used threshold
.build();
KOOM.getInstance().setKConfig(kConfig);
}

//Example of how to set custom logger.
public void customLogger() {
KOOM.getInstance().setLogger(new KLog.KLogger() {
@Override
public void i(String TAG, String msg) {
//get the log of info level
}

@Override
public void d(String TAG, String msg) {
//get the log of debug level
}

@Override
public void e(String TAG, String msg) {
//get the log of error level
}
});
}

//Example of set custom koom root dir.
public void customRootDir() {
KOOM.getInstance().setRootDir(this.getCacheDir().getAbsolutePath());
}

}

0 comments on commit 03c1afa

Please sign in to comment.