diff --git a/app/src/main/java/cz/martykan/forecastie/AlarmReceiver.java b/app/src/main/java/cz/martykan/forecastie/AlarmReceiver.java index e97324bd..57e8d288 100644 --- a/app/src/main/java/cz/martykan/forecastie/AlarmReceiver.java +++ b/app/src/main/java/cz/martykan/forecastie/AlarmReceiver.java @@ -67,8 +67,8 @@ private void getWeather() { if (isUpdateLocation()) { new GetLocationAndWeatherTask().execute(); // This method calls the two methods below once it has determined a location } else { - new GetWeatherTask().execute(); - new GetLongTermWeatherTask().execute(); + new GetWeatherTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + new GetLongTermWeatherTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } else { failed = true; @@ -227,8 +227,8 @@ protected void onPostExecute(Void aVoid) { new GetCityNameTask().execute(String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); } else { Log.e(TAG, "Couldn't determine location. Using last known location."); - new GetWeatherTask().execute(); - new GetLongTermWeatherTask().execute(); + new GetWeatherTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + new GetLongTermWeatherTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } try { locationManager.removeUpdates(locationListener); diff --git a/app/src/main/java/cz/martykan/forecastie/activities/MainActivity.java b/app/src/main/java/cz/martykan/forecastie/activities/MainActivity.java index ca3609c7..88a1a190 100644 --- a/app/src/main/java/cz/martykan/forecastie/activities/MainActivity.java +++ b/app/src/main/java/cz/martykan/forecastie/activities/MainActivity.java @@ -15,6 +15,7 @@ import android.location.LocationManager; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.os.AsyncTask; import android.os.Bundle; import android.preference.PreferenceManager; import android.provider.Settings; @@ -201,11 +202,11 @@ private void preloadWeather() { String lastToday = sp.getString("lastToday", ""); if (!lastToday.isEmpty()) { - new TodayWeatherTask(this, this, progressDialog).execute("cachedResponse", lastToday); + new TodayWeatherTask(this, this, progressDialog).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "cachedResponse", lastToday); } String lastLongterm = sp.getString("lastLongterm", ""); if (!lastLongterm.isEmpty()) { - new LongTermWeatherTask(this, this, progressDialog).execute("cachedResponse", lastLongterm); + new LongTermWeatherTask(this, this, progressDialog).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "cachedResponse", lastLongterm); } }