Android Question Get data from webview without using webviewextras

Siam

Active Member
Licensed User
Hi,

Is there a solution to inject data from a webview into B4A WITHOUT the use of webviewextras (i use this for File Upload https://www.b4x.com/android/forum/threads/upload-files-with-webview.98623/) so I can't use wve to solve this problem.

I have tried a second webview with wve but this isn't working.

I need some data from the webview which I only can get when the user is logged in.
webviewextras would be a perfect solution but it manipulates the main webview :(

And now is search a solution which not kills my main webview.

Greeting

Andy
 

Erel

Administrator
Staff member
Licensed User
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private WebView1 As WebView
End Sub

Public Sub Initialize
    
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    WebView1.LoadUrl("https://www.b4x.com")
End Sub


Sub Button1_Click
    Dim s As String = $"
    (function() { 
            return document.title;
        }
    )();
    "$
    Wait For (EvaluateJavaScript(WebView1, s)) Complete (Result As Object)
    Log(Result)
End Sub

Sub EvaluateJavaScript (wv As WebView, js As String) As ResumableSub
    Dim jo As JavaObject = wv
    Dim ValueCallback As Object = jo.CreateEventFromUI("android.webkit.ValueCallback", "ReceiveValue", Null)
    jo.RunMethod("evaluateJavascript", Array(js, ValueCallback))
    Wait For (jo) ReceiveValue_Event (MethodName As String, Args() As Object)
    Return Args(0)
End Sub
 
Top