diff options
Diffstat (limited to 'org.fox.ttrss/src')
-rwxr-xr-x[-rw-r--r--] | org.fox.ttrss/src/main/java/org/fox/ttrss/tasker/TaskerReceiver.java | 18 | ||||
-rwxr-xr-x | org.fox.ttrss/src/main/java/org/fox/ttrss/widget/WidgetUpdateService.java | 13 |
2 files changed, 22 insertions, 9 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/tasker/TaskerReceiver.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/tasker/TaskerReceiver.java index 0bac722a..52c600bf 100644..100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/tasker/TaskerReceiver.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/tasker/TaskerReceiver.java @@ -4,6 +4,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; @@ -43,8 +44,12 @@ public class TaskerReceiver extends BroadcastReceiver { OfflineDownloadService.class); intent.putExtra("sessionId", sessionId); intent.putExtra("batchMode", true); - - fContext.startService(intent); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + fContext.startForegroundService(intent); + } else { + fContext.startService(intent); + } } break; case TaskerSettingsActivity.ACTION_UPLOAD: @@ -53,8 +58,13 @@ public class TaskerReceiver extends BroadcastReceiver { OfflineUploadService.class); intent.putExtra("sessionId", sessionId); intent.putExtra("batchMode", true); - - fContext.startService(intent); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + fContext.startForegroundService(intent); + } else { + fContext.startService(intent); + } + } break; default: diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/widget/WidgetUpdateService.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/widget/WidgetUpdateService.java index efb0fcf1..d54d4422 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/widget/WidgetUpdateService.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/widget/WidgetUpdateService.java @@ -6,6 +6,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.os.Build; import android.os.Handler; import android.os.IBinder; import android.preference.PreferenceManager; @@ -43,10 +44,7 @@ public class WidgetUpdateService extends Service { // if no network is available networkInfo will be null // otherwise check if we are connected - if (networkInfo != null && networkInfo.isConnected()) { - return true; - } - return false; + return networkInfo != null && networkInfo.isConnected(); } @Override @@ -67,7 +65,12 @@ public class WidgetUpdateService extends Service { public void run() { Intent serviceIntent = new Intent(getApplicationContext(), WidgetUpdateService.class); serviceIntent.putExtra("retryCount", retryCount + 1); - startService(serviceIntent); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + startForegroundService(serviceIntent); + } else { + startService(serviceIntent); + } } }, 3 * 1000); |