With reference to this post: https://www.b4x.com/android/forum/t...hrough-orientation-change.104143/#post-652932
I need to know how to use a list of bundles.
So my current approach is:
This is clearly not a good practice and is in violation of the DRY principle. I would prefer a more elegant solution that uses a list of bundles.
So I created something like this:
However when I implement such a solution I get a java error when I try to restore the webview state:
java.lang.RuntimeException: Method: restoreState not matched.
Can you please advise the correct way to implement a list of bundles.
I need to know how to use a list of bundles.
So my current approach is:
B4X:
Sub Process_Globals
Private Bundle0 As JavaObject
Private Bundle1 As JavaObject
Private Bundle2 As JavaObject
Private Bundle3 As JavaObject
'etc...
End Sub
This is clearly not a good practice and is in violation of the DRY principle. I would prefer a more elegant solution that uses a list of bundles.
So I created something like this:
B4X:
Sub Process_Globals
'Bundle
Private bundleList As List
Private bundle As JavaObject
End Sub
'... Other stuff here
Sub Activity_Pause (UserClosed As Boolean)
bundleList.Initialize
If UserClosed Then
'User Closed
Else
'Save State
For n = 0 To webviewList.size -1
bundle.InitializeNewInstance("android.os.Bundle", Null)
Dim javaObject_ As JavaObject = webviewList.get(n)
javaObject_.RunMethod("saveState", Array(bundle))
bundleList.Add(javaObject_)
Next
End If
End Sub
However when I implement such a solution I get a java error when I try to restore the webview state:
java.lang.RuntimeException: Method: restoreState not matched.
Can you please advise the correct way to implement a list of bundles.