use back key to exit app when using a webview

rthyoung26

Member
Licensed User
Longtime User
I have a webview as part of an app and use the back key to backup up through the previously displayed pages - pretty straight forward. However, when there are no more previously displayed webpages to display, how can I get the app to close when I click the back button again? Commercial browsers behave this way. Is there a way to check if there are no more pages to display and control the exit that way? I have a menu button to exit app but would like the back key to do it if it is possible.

Sub activity_KeyPress (KeyCode As Int) As Boolean

If KeyCode = KeyCodes.KEYCODE_BACK Then
WebView1.Back
Return True
End If

End Sub
 

Ionut Indigo

Member
Licensed User
Longtime User
How can i use canGoBack with Reflector, with this code, so when there are no more pages to go back to in the WebView , and press back again the application closes?


B4X:
Sub LoadSite
site.LoadUrl("http://test.co.uk")
End Sub

Sub Activity_KeyPress(KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then

closeCntr = closeCntr + 1
If closeCntr = 2 Then
closeCntr = 0
ExitApplication

Else

ToastMessageShow("Back 2 Exit", True)
Return True
End If
End If
End Sub
 
Upvote 0

CapVidia

New Member
Licensed User
Longtime User
I found this thread by searching the same thing rthyoung26 was asking, and Penguin camed out with the solution for it, i'll leave the link here for the double back key code to exit the app - Click!
 
Upvote 0
Top