App closing when pressing go back button

jisuskraist

I have an application that has the next diagram

http://i.stack.imgur.com/bSIFw.jpg

Once i arrive to activity B with the different previous path if I do home button and open the app again, correctly activity B is displayed BUT if I use "go back" button instead of home button, when I open the app again I get Activity A displayed instead of the last one that was Activity B.

Im finishing all my previous activity, one I arrive B, B is the only one active, all the previous (ACD) were close because If i hit "go back" on Activity B button i dont wanna go neither to AC or D just act send the app to the background.

njzk2

When you press back, by default you finish the current activity.

If all your others activities are finished as well, the next time the application is opened, it can only open the default entry point (in your case A)

To achieve what you are trying to do, you have to keep your activities unfinished (therefore in the back stack), and override the behavior of the back button in B:

public void onBackPressed() {
     moveTaskToBack(true);
}

This will put B in paused state, reveal the previous application (can be home, or can be an application from which you called your own application). Next time you start the application, it can be resumed directly in B.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Blank activity or fragment on reopening app after closing by pressing back button

From Dev

When pressing the back button on the phone, the app minimizes

From Dev

App closes on pressing back button when trying to move to previous fragment

From Dev

Error when pressing back button

From Dev

Back button closing app even when using FragmentTransaction.addToBackStack()

From Dev

Back button closing app even when using FragmentTransaction.addToBackStack()

From Dev

Android activity go back to activity that started it instead of parent activity when pressing navigation bar back button

From Dev

How to go to previous selected tab when pressing an activity action bar back button

From Dev

Android runOnUiThread crash when pressing Back button

From Dev

Back button is not closing APP in Samsung Devices

From Dev

pressing back button from toolbar minimizes the app when opened from notification

From Dev

Pressing home button and going back into the app causes the app to crash

From Dev

How to go to root activity from any fragment by pressing back button?

From Dev

How to go to root activity from any fragment by pressing back button?

From Dev

When back button is pressed and navigation drawer is open, my app closes instead of closing drawer

From Dev

App Keeps Stopping when pressing a button

From Dev

Back button closing app instead of going back on Windows Phone 8.1

From Dev

Fragment pressing back button

From Dev

Android App Not Closing Properly When Clicking Back

From Dev

going back to the parent activity on pressing app icon button

From Dev

Pressing back button stops app during Camera activity

From Dev

What is the effect of pressing the back button on the app's process in android?

From Dev

going back to the parent activity on pressing app icon button

From Dev

Android: app crashes after going back and pressing a button

From Dev

Avoid splash screen activity when pressing Back button

From Dev

Ajax "POST" is showing form entries in URL when pressing back button

From Dev

Don't kill Activity when pressing back button

From Dev

Going to the apps screen when pressing the back button in android

From Dev

addToBackStack() duplicating original fragment when pressing back button

Related Related

  1. 1

    Blank activity or fragment on reopening app after closing by pressing back button

  2. 2

    When pressing the back button on the phone, the app minimizes

  3. 3

    App closes on pressing back button when trying to move to previous fragment

  4. 4

    Error when pressing back button

  5. 5

    Back button closing app even when using FragmentTransaction.addToBackStack()

  6. 6

    Back button closing app even when using FragmentTransaction.addToBackStack()

  7. 7

    Android activity go back to activity that started it instead of parent activity when pressing navigation bar back button

  8. 8

    How to go to previous selected tab when pressing an activity action bar back button

  9. 9

    Android runOnUiThread crash when pressing Back button

  10. 10

    Back button is not closing APP in Samsung Devices

  11. 11

    pressing back button from toolbar minimizes the app when opened from notification

  12. 12

    Pressing home button and going back into the app causes the app to crash

  13. 13

    How to go to root activity from any fragment by pressing back button?

  14. 14

    How to go to root activity from any fragment by pressing back button?

  15. 15

    When back button is pressed and navigation drawer is open, my app closes instead of closing drawer

  16. 16

    App Keeps Stopping when pressing a button

  17. 17

    Back button closing app instead of going back on Windows Phone 8.1

  18. 18

    Fragment pressing back button

  19. 19

    Android App Not Closing Properly When Clicking Back

  20. 20

    going back to the parent activity on pressing app icon button

  21. 21

    Pressing back button stops app during Camera activity

  22. 22

    What is the effect of pressing the back button on the app's process in android?

  23. 23

    going back to the parent activity on pressing app icon button

  24. 24

    Android: app crashes after going back and pressing a button

  25. 25

    Avoid splash screen activity when pressing Back button

  26. 26

    Ajax "POST" is showing form entries in URL when pressing back button

  27. 27

    Don't kill Activity when pressing back button

  28. 28

    Going to the apps screen when pressing the back button in android

  29. 29

    addToBackStack() duplicating original fragment when pressing back button

HotTag

Archive