How do I use StateManager to preserve a WebView through orientation change. In particular I need to preserve the webview backforward history. I have attached a sample project which has both WebView and StateManager attached.
Please advise how to modify it so that it can also preserve the WebView state.
Example of saving WebView state when the orientation changes:
B4X:
Sub Process_Globals
Private Bundle As JavaObject
End Sub
Sub Globals
Private WebView1 As WebView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
If Bundle.IsInitialized Then
Dim jo As JavaObject = WebView1
jo.RunMethod("restoreState", Array(Bundle))
Else
WebView1.LoadUrl("https://www.b4x.com")
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
Bundle.InitializeNewInstance("android.os.Bundle", Null)
Dim jo As JavaObject = WebView1
jo.RunMethod("saveState", Array(Bundle))
End Sub
Sub btnBack_Click
WebView1.Back
End Sub
Sub btnForward_Click
WebView1.Forward
End Sub
Example of saving WebView state when the orientation changes:
B4X:
Sub Process_Globals
Private Bundle As JavaObject
End Sub
Sub Globals
Private WebView1 As WebView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
If Bundle.IsInitialized Then
Dim jo As JavaObject = WebView1
jo.RunMethod("restoreState", Array(Bundle))
Else
WebView1.LoadUrl("https://www.b4x.com")
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
Bundle.InitializeNewInstance("android.os.Bundle", Null)
Dim jo As JavaObject = WebView1
jo.RunMethod("saveState", Array(Bundle))
End Sub
Sub btnBack_Click
WebView1.Back
End Sub
Sub btnForward_Click
WebView1.Forward
End Sub