Android Question Msgbox2 and Activity.finish

Tjitte Dijkstra

Member
Licensed User
I try to finish the program by activity.finish, but only after the user gets the possibility to go on.
See my code. What did I do wrong?

B4X:
Sub STOP_Click
Dim result As Int
    Msgbox2("You want to stop?","","Go on","","Stop",LoadBitmap(File.DirAssets,"upblack.jpg"))
        If result = DialogResponse.NEGATIVE Then Activity.finish   
End Sub
 

DonManfred

Expert
Licensed User
1. Why did you dim an int result? You dont need and you dont USE it.
2. Msgbox2 gives a result. Why are you not using it?

B4X:
  If Msgbox2("You want to stop?","","Go on","","Stop", Null) = DialogResponse.NEGATIVE Then
        Activity.finish 
    End If
i set null to the image cause i dont have this file

BUT to make your code running you need to write it like this

B4X:
Sub STOP_Click
Dim result As Int
    result = Msgbox2("You want to stop?","","Go on","","Stop",LoadBitmap(File.DirAssets,"upblack.jpg"))
        If result = DialogResponse.NEGATIVE Then 
          Activity.finish   
        End if
End Sub
 
Top