Hello every one.
in the folloowing code I use WebviewExtras2.AddJavascriptInterface to call a sub from B4a .
but it never works , and I cant figure out the problem with this code and why the 'MyFunction' never gets reached
Also I'm not sure about the first parameter to the 'AddJavascriptInterface ' should it be the webview instance or the B4A Module ?
Any help would be appreciated .
Code:
#Region Project Attributes
#ApplicationLabel: Golden Van Sales
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: true
#IncludeTitle: false
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim wve As WebViewExtras
Private WebView1 As WebView
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
End If
Dim wc As DefaultWebChromeClient
WebView1.Initialize("WebView1")
wc.Initialize("wc1")
wve.Initialize(WebView1)
wve.SetWebChromeClient( wc)
Activity.AddView(WebView1,0,0,90%x,90%y)
WebView1.LoadHtml("<html><body>Hello world! <button onclick=" & Chr(34) & "B4A.CallSub('MyFunction',true);" & Chr(34) & ">KOKO</button> </body></html>")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub MyFunction(x As String)
Msgbox("It Works",x)
End Sub
Sub WebView1_PageFinished (Url As String)
WebView1.JavaScriptEnabled=True
wve.JavaScriptEnabled=True
'wve.AddJavascriptInterface(Me ,"B4A")
wve.AddJavascriptInterface(WebView1 ,"B4A")
End Sub
in the folloowing code I use WebviewExtras2.AddJavascriptInterface to call a sub from B4a .
but it never works , and I cant figure out the problem with this code and why the 'MyFunction' never gets reached
Also I'm not sure about the first parameter to the 'AddJavascriptInterface ' should it be the webview instance or the B4A Module ?
Any help would be appreciated .
Code:
#Region Project Attributes
#ApplicationLabel: Golden Van Sales
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: true
#IncludeTitle: false
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim wve As WebViewExtras
Private WebView1 As WebView
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
End If
Dim wc As DefaultWebChromeClient
WebView1.Initialize("WebView1")
wc.Initialize("wc1")
wve.Initialize(WebView1)
wve.SetWebChromeClient( wc)
Activity.AddView(WebView1,0,0,90%x,90%y)
WebView1.LoadHtml("<html><body>Hello world! <button onclick=" & Chr(34) & "B4A.CallSub('MyFunction',true);" & Chr(34) & ">KOKO</button> </body></html>")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub MyFunction(x As String)
Msgbox("It Works",x)
End Sub
Sub WebView1_PageFinished (Url As String)
WebView1.JavaScriptEnabled=True
wve.JavaScriptEnabled=True
'wve.AddJavascriptInterface(Me ,"B4A")
wve.AddJavascriptInterface(WebView1 ,"B4A")
End Sub