Skip to content

Commit

Permalink
Merge pull request #368 from prkay/fix/android_crash_watchdog_receiver
Browse files Browse the repository at this point in the history
add try catch block to stop crash
  • Loading branch information
ekasetiawans authored Nov 6, 2023
2 parents 1a63827 + 1a6927b commit 0738aa1
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ public void onReceive(Context context, Intent intent) {
}

if (!config.isManuallyStopped() && !isRunning) {
if (config.isForeground()) {
ContextCompat.startForegroundService(context, new Intent(context, BackgroundService.class));
} else {
context.startService(new Intent(context, BackgroundService.class));
try {
if (config.isForeground()) {
ContextCompat.startForegroundService(context, new Intent(context, id.flutter.flutter_background_service.BackgroundService.class));
} else {
context.getApplicationContext().startService(new Intent(context, id.flutter.flutter_background_service.BackgroundService.class));
}}
catch (Exception e){
e.printStackTrace();
}
}
}
Expand Down

0 comments on commit 0738aa1

Please sign in to comment.