Commit 70d0952f authored by Tiago Cunha's avatar Tiago Cunha

Enables StrictMode with log penalty

parent 7694ff8a
package chat.rocket.android;
import android.os.StrictMode;
import android.support.multidex.MultiDexApplication;
import com.facebook.stetho.Stetho;
import com.uphyca.stetho_realm.RealmInspectorModulesProvider;
......@@ -19,6 +20,10 @@ import chat.rocket.persistence.realm.RocketChatPersistenceRealm;
public class RocketChatApplication extends MultiDexApplication {
@Override
public void onCreate() {
if (BuildConfig.DEBUG) {
enableStrictMode();
}
super.onCreate();
RocketChatPersistenceRealm.init(this);
......@@ -39,4 +44,18 @@ public class RocketChatApplication extends MultiDexApplication {
RocketChatWidgets.initialize(this, OkHttpHelper.getClientForDownloadFile(this));
}
private void enableStrictMode() {
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()
.build());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment