Android & Ionic v5: exitApp() causes app to restart on reopen

This Question is about Ionic v5 (@ionic/angular 5.3.1) and Capacitor (@capacitor/android 2.4.0).

I’ve implemented the hardware back button close feature like this:

    this.platform.backButton.subscribeWithPriority(1, () => {
      if (!this.routerOutlet.canGoBack()) {

And the code above nearly works as expected.

The Problem:
When my users exit the app via the hardware back button, the app seems to exit completely. When they check the open apps in the background the app is still there. But when they reopen the app, the splash screen is shown and the app restarts as if it was exited completely. (Although it still was shown in the background list!). This also happens even if they reopen the app just a second later (no other app opened in-between).

When they use the hardware home button, and then re-enter the app is still there and does not restart. This is the behavior I’m actually intending to implement for the hardware back button.

Have you guys any suggestions on how to fix that?

The App indeed seems to crash in the background. I’ve attached my android device via usb and started the debugger before using the hardware back button to close the app. The debugger notices a crash, but sadly there is no further info.


I assume this might be a capacitor bug. Therefore I’ve created an issue: