Android Question Why Close the app couse app restart automatically?

nickysuwandi

Member
Licensed User
i want to close the app when user click return button, using code below, but the app restart automatically.

B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
    If KeyCode = KeyCodes.KEYCODE_BACK Then
        If Msgbox2("Do you want to close?", "", "Yes","", "No", Null) = DialogResponse.POSITIVE Then
            ExitApplication 'App is exiting
        Else
            Return True
        End If
    End If
End Sub
if i change " Exit Application " to "Activity.Finish", the app will display blank screen and not close the apps.

Some Expert may help me, where is wrong in my code???

Thanks

Nicky
 

kisoft

Well-Known Member
Licensed User
HI
Do not use Exit Application. Do not do anything, the android will close the activity after some time.
 

MarkusR

Well-Known Member
Licensed User
Better use Msgbox2Async
 

nickysuwandi

Member
Licensed User
Thanks Kisoft and MarkusR, i had solve my problem.

the app display blank screen, because i am ExitApplication not in the first loading screen.
 
Top