diff --git a/hyperroid/app/src/main/AndroidManifest.xml b/hyperroid/app/src/main/AndroidManifest.xml index 69dfbbb5..35bb4c4d 100644 --- a/hyperroid/app/src/main/AndroidManifest.xml +++ b/hyperroid/app/src/main/AndroidManifest.xml @@ -6,6 +6,8 @@ + + @@ -25,7 +27,12 @@ android:name=".HyperSettings"> - + + = Build.VERSION_CODES.S) { + try { + startForegroundService(startIntent); + } catch (ForegroundServiceStartNotAllowedException e) { + Log.e("HyperRogue", "Cannot start foreground service", e); + } + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + startForegroundService(startIntent); + } else { + startService(startIntent); + } } else { - Intent stopIntent = new Intent(HyperRogue.this, ForegroundService.class); - stopIntent.setAction(ForegroundService.STOPFOREGROUND_ACTION); - startService(stopIntent); + // Intent stopIntent = new Intent(HyperRogue.this, ForegroundService.class); + // stopIntent.setAction(ForegroundService.STOPFOREGROUND_ACTION); + // startService(stopIntent); + stopService(new Intent(HyperRogue.this, ForegroundService.class)); } if (backgroundmusic != null) backgroundmusic.stop();