Skip to content

make app suspend instead of exit #4275

@1u0n

Description

@1u0n

my app creates a worker that keeps a connection open with the server and receives messages.

  • When the user navigates away from the app it gets suspended, which doesn't kill the worker and messages still arrive.

  • But when the user leaves pressing the back button, 90% of the times the app exits, the worker gets killed, connection to server cut and messages don't arrive anymore (I guess Android some times decides not to kill it, that's the other 10%).

Is there any cross-platform way to catch that back button event that would exit the app, and make it minimize, suspend instead?

In the long term Android will kill the app if the user doesn't interact with it again, and that's ok, I'm just interested in not killing it straight away because of the back button.

I see the application module has an AndroidActivityBackPressedEventData with a cancel property, but I can't find a way to generate the suspend event instead, and in a cross-platform manner.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions