-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Pressing "Back" Button closes App(High Priority BUG) #173
Comments
@AkkiBond I think this can be fixed by raising the alert dialog before closing the app or showing a toast notification if the user presses back button first time like "Press again for closing the app" |
Yes But it should only be when user presses back button two times. Otherwise what is the use of back button if we can't go back to our last activity. |
@AkkiBond yes on first press it will show the toast and then it will ask for pressing it again. |
@robustTechie I'm trying to trace that problem and fix it with a PR. |
duplicate of #143 |
Developer should not display URL's on network failure. You can hide such webview based errors by display static web page on getting any webpage access error:
Also you can minimize the app on pressing back button..
Same replied on #143 |
Or we can just use the addToBackStack() and that would make sure we go back to the previous activity and if there is none the app exits. |
@AkkiBond Please check for existing issues before opening a new one. You can close this and proceed there. Duplicate of #7 |
There is problem with Intent that doesn't save the last activity because of that the app directly closes rather than going back to last running activity. like in FAQ section when we try to get back to last activity it closes the whole application.
We need to use Intents to "switch windows". To launch another Activity from our current Activity, simply create an Intent with a few parameters and call startActivity() with that Intent. Here's an example:
Intent i = new Intent(this, TheNextActivity.class); startActivity(i)
Don't forget to include your second Activity in the Android manifest file. All Activities in your application must be included in that file.
Other things to note is that we don't really use System.exit() in Android. Just call finish(). It's advised to let Android manage applications and its resources rather than doing it yourself, but if we want to make sure that your application really is shut down, feel free to use System.exit() anyway. There's also no need for overriding onBackPressed() if you're only calling finish(). That's standard behaviour in Android when we hit the back button.
Also, you don't call setContentView() more than once per Activity. You start a new Activity when you need to change the visuals (or use one of the specialized Widgets to switch between layouts.
This also explains why we're experiencing your "problem". You may have changed the layout of the Activity using setContentView(), but there's still only one Activity running - when you call finish(), that Activity gets closed. If you had started a second Activity with a different layout, like you're supposed to do, Android would have closed that second Activity and would have returned you to the first.
The text was updated successfully, but these errors were encountered: