Android Question "Save or discard" - question at exit

grafsoft

Well-Known Member
Licensed User
Longtime User
Hi,

this is what I want to do:

B4X:
Sub Activity_Pause (UserClosed As Boolean)
   If UserClosed Then
     If Msgbox2("Speichern?","?","Ja","","Nein",Null)=DialogResponse.Positive Then
       ToastMessageShow ("gespeichert",True)
     End If
   End If
End Sub

But of course this is not possible.

But wherre can I place such a question before closing an activity? I want the user to decide if he wants to save his changes or not.

Thank you
 

klaus

Expert
Licensed User
Longtime User
You should trap the back key.
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
   
    If KeyCode = KeyCodes.KEYCODE_BACK Then
        ' your code
        ' Return True  ' uncomment this line if you want to consume the event
    Else
        ' other code
    End If
Return False
 
Upvote 0
Top