diff options
Diffstat (limited to 'org.fox.ttrss/src/main/java/org/fox/ttrss/widget/WidgetUpdateService.java')
-rwxr-xr-x | org.fox.ttrss/src/main/java/org/fox/ttrss/widget/WidgetUpdateService.java | 13 |
1 files changed, 8 insertions, 5 deletions
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); |