Skip to content

High performance self-hosted photo and video management solution.

fix Android BackgroundServiceStartNotAllowedException (#687)

Fynn Petersen-Frey789bc8563c26
diff --git a/mobile/android/app/src/main/kotlin/com/example/mobile/MainActivity.kt b/mobile/android/app/src/main/kotlin/com/example/mobile/MainActivity.kt
index f16acc394e..2e6372231d 100644
--- a/mobile/android/app/src/main/kotlin/com/example/mobile/MainActivity.kt
+++ b/mobile/android/app/src/main/kotlin/com/example/mobile/MainActivity.kt
@@ -14,7 +14,12 @@ class MainActivity: FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- startService(Intent(getBaseContext(), AppClearedService::class.java));
+ try {
+ startService(Intent(getBaseContext(), AppClearedService::class.java));
+ } catch (e: Exception) {
+ // startService must not be called when app is in background (crashes app)
+ // there is nothing we can do
+ }
}
}