Android Question How to enable GPS with WebView?

WebQuest

Active Member
Licensed User
Longtime User
Hi, I want to use my web app in a webview. The problem is that the web app is written in React and JS and uses GPS, mic, and webcam. In browsers like Chrome, everything works, but with Webview, I can't enable GPS, mic, etc. because Webview doesn't allow it and the request is denied. Does anyone know how to do this?
[CODE lang="b4x" title="b4a"]Sub Globals
'These global variables will be redeclared each time the activity is created.
Private WebView1 As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
WebView1.JavaScriptEnabled = True

Dim wve As WebViewExtras
wve.Initialize(WebView1)

Dim jo As JavaObject = WebView1
Dim settings As JavaObject = jo.RunMethod("getSettings", Null)
Dim jo As JavaObject = WebView1
Dim settings As JavaObject = jo.RunMethod("getSettings", Null)
Dim wc As JavaObject
wc.InitializeNewInstance("android.webkit.WebChromeClient", Null)
wc = wc.CreateEvent("android.webkit.WebChromeClient", "GeoClient", Null)
jo.RunMethod("setWebChromeClient", Array(wc))
WebView1.LoadUrl("https://facelive.net")
End Sub

Sub Activity_Resume
If rp.Check(rp.PERMISSION_ACCESS_FINE_LOCATION) = False Then
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
End If

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

[/CODE]
 
It seems that this is not possible with a webview in b4a. Even if the code does not return an error, it does not intercept the website and therefore automatically rejects the request.
 
Upvote 0
Back
Top