diff --git a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java index a811f068ec..e465cc6b5b 100644 --- a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java +++ b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java @@ -25,6 +25,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; public class CurrentPositionHelper { @@ -36,6 +38,7 @@ public class CurrentPositionHelper { private ApplicationMode am; private List usedReaders = new ArrayList<>(); private static final org.apache.commons.logging.Log log = PlatformUtil.getLog(CurrentPositionHelper.class); + private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); public CurrentPositionHelper(OsmandApplication app) { this.app = app; @@ -99,7 +102,7 @@ public class CurrentPositionHelper { } return null; } - }.execute((Void) null); + }.executeOnExecutor(singleThreadExecutor, (Void) null); res = true; } return res; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 7bc3921d6e..d9956f280e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -136,6 +136,8 @@ import java.util.List; import java.util.Map; import java.util.Timer; import java.util.TimerTask; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -200,6 +202,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven private InAppHelper inAppHelper; private Timer splashScreenTimer; + private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); + @Override public void onCreate(Bundle savedInstanceState) { setRequestedOrientation(AndroidUiHelper.getScreenOrientation(this)); @@ -1234,7 +1238,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven protected void onPostExecute(Void result) { } - }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null); + }.executeOnExecutor(singleThreadExecutor, (Void) null); } diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index c11773f884..f20145a8f1 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -78,6 +78,8 @@ import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import static net.osmand.plus.OsmandApplication.SHOW_PLUS_VERSION_INAPP_PARAM; @@ -125,6 +127,8 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo private boolean nauticalPluginDisabled; private boolean freeVersion; + private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); + @Override protected void onCreate(Bundle savedInstanceState) { getMyApplication().applyTheme(this); @@ -784,7 +788,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo newDownloadIndexes(); } }; - task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + task.executeOnExecutor(singleThreadExecutor); } diff --git a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java index 984c69fe6c..07f06e06ef 100644 --- a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java +++ b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java @@ -23,6 +23,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; public class CurrentPositionHelper { @@ -33,6 +35,7 @@ public class CurrentPositionHelper { private List readers = new ArrayList<>(); private List usedReaders = new ArrayList<>(); private static final org.apache.commons.logging.Log log = PlatformUtil.getLog(CurrentPositionHelper.class); + private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); public CurrentPositionHelper(SampleApplication app) { this.app = app; @@ -103,7 +106,7 @@ public class CurrentPositionHelper { } return null; } - }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null); + }.executeOnExecutor(singleThreadExecutor, (Void) null); res = true; } return res;