Android Question Deleting the view stack when home button is pressed

rleiman

Well-Known Member
Licensed User
Longtime User
Hi,

I would like to delete the view stack when the phone's home button is pressed.

In my app the user taps the "Settings" button from the main screen to display the settings screen. Instead of tapping the "Main Menu" button to take them back to the main screen, they press the phone's home button. When they start the app again, the main screen is displayed. If they try to exit the app by tapping the "Exit" button from the main screen, the settings screen is displayed instead of exiting the app. If they try to tap the "Main Menu" button now, the app exits.

I think if there is a way to delete the view stack this will not happen.

Thanks.
 

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Erel,

Thanks for the location to issue the command to delete the view stack but I also need the actual command. I looked for it in both the beginners guide and the user guide but could not find it.

Thanks.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
There is no "command" for this
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Don,

I see many other apps where I can press the phone's home button but it doesn't mess up the order of screens in the apps. Can you show me how they do it?

Thanks.
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Don,

I will try that. I will put it in the area Erel suggested which is Activity_Pause because I'm already using it from an "Exit" button.
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Don,

It worked. Here's the code from my settings activity module:
B4X:
Sub Activity_Pause (UserClosed As Boolean)

    If UserClosed = False Then
        Activity.Finish   
    End If
End Sub

Thanks Erel and Don. :)
 
Upvote 0
Top