Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimize the app instead of killing it as default back behavior #2728

Closed
willlaserlike opened this issue Feb 15, 2018 · 2 comments
Closed

Minimize the app instead of killing it as default back behavior #2728

willlaserlike opened this issue Feb 15, 2018 · 2 comments

Comments

@willlaserlike
Copy link

willlaserlike commented Feb 15, 2018

Hello everyone,

I'd like get some input on the idea of default Android back button behavior for navigation when it's the last activity on a stack.

The current implementation is to kill the activity and causes a much longer time to start the app next time. I'm proposing to only minimizing the app as an alternative.

Issue Description

I got inspired by this comment.
#1022 (comment)

Steps to Reproduce / Code Snippets / Screenshots

  • Install the example app on an Android device
  • Open the App, press Home button, open the app again. Notice the app resumes instantly.
  • Open the app, press Back button to leave the app, open the app again. Notice the app go through a cold starting thus more slower than the previous way

Environment

  • Platform(s) (iOS, Android, or both?): Android only
@guyca
Copy link
Collaborator

guyca commented Feb 15, 2018

Hey there

Back button should kill the activity if there's nothing to pop. The issue which you've linked to proposes a solution to the problem, as it will greatly speed up launch time. We use it in the Wix app with great success, and that's the default behaviour in v2.
Alternatively, you can override the back button in your root screen by setting overrideBackPress: true in tab declaration .

Navigation.startTabBasedApp({
  tabs: [
    {
      label: 'Navigation',
      screen: 'example.Types',
      icon: require('../img/list.png'),
      title: 'Navigation Types',
      overrideBackPress: true
    }, {
      label: 'Actions',
      screen: 'example.Actions',
      icon: require('../img/swap.png'),
      title: 'Navigation Actions',
      overrideBackPress: true
    }
  ]
})

Then, listen to backPress navigation event in the root screens and programatically send the app to the background (you'll need to do some native work here I think, starting the launcher intent is one way of achieving this)

regardless, overriding back handling isn't something RNN should be responsible so I'm opting to close the issue.
Best of luck

@guyca guyca closed this as completed Feb 15, 2018
@rintran720
Copy link

@guyca If a set overrideBackPress: true, how do i make a back to previous screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants