Handle O's new foreground policy
this makes sure our service is always allowed to start
@@ -118,8 +118,12 @@ public class ServerSyncService extends Service {
public static void startService() {
App app = App.components().app();
Intent syncServiceIntent = new Intent(app, ServerSyncService.class);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ app.startForegroundService(syncServiceIntent);
+ } else {
app.startService(syncServiceIntent);
}
+ }
public static void stopService() {
App app = App.components().app();
