diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index a9cc116361..5b7547854e 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -29,6 +29,7 @@ import net.osmand.plus.api.InternalToDoAPI; import net.osmand.plus.api.SQLiteAPI; import net.osmand.plus.api.SQLiteAPIImpl; import net.osmand.plus.api.SettingsAPI; +import net.osmand.plus.api.ExternalServiceAPI.AudioFocusHelper; import net.osmand.plus.render.NativeOsmandLibrary; import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.resources.ResourceManager; @@ -105,10 +106,13 @@ public class OsmandApplication extends Application implements ClientContext { public void onCreate() { long timeToStart = System.currentTimeMillis(); if (Version.getAppName(this).equals("OsmAnd~")) { - StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskWrites().detectNetwork().detectCustomSlowCalls(). - detectDiskReads(). - penaltyLog()./*penaltyDeath().*/build()); - StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog()./*penaltyDeath().*/build()); + if (android.os.Build.VERSION.SDK_INT >= 9) { + try { + Class.forName("net.osmand.plus.base.EnableStrictMode").newInstance(); + } catch (Exception e) { + e.printStackTrace(); + } + } } super.onCreate(); diff --git a/OsmAnd/src/net/osmand/plus/base/EnableStrictMode.java b/OsmAnd/src/net/osmand/plus/base/EnableStrictMode.java new file mode 100644 index 0000000000..df1e947c97 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/base/EnableStrictMode.java @@ -0,0 +1,13 @@ +package net.osmand.plus.base; + +import android.os.StrictMode; + +public class EnableStrictMode { + + public EnableStrictMode(){ + StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskWrites().detectNetwork().detectCustomSlowCalls(). + detectDiskReads(). + penaltyLog()./*penaltyDeath().*/build()); + StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog()./*penaltyDeath().*/build()); + } +}