fix Android BackgroundServiceStartNotAllowedException (#687)

This commit is contained in:
Fynn Petersen-Frey 2022-09-14 03:12:31 +02:00 committed by GitHub
parent 99a50f70dd
commit 789bc8563c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,7 +14,12 @@ class MainActivity: FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
try {
startService(Intent(getBaseContext(), AppClearedService::class.java)); 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
}
} }
} }