Android Question How can I get the webview to accept camera permission from my Gethub website?


Licensed User
I have a AR website that works great on my desktop. It also works on my mobile if I use the chrome browser. How can I get the webview to accept the permission? In a B4X webview. What am i doing wrong here. I get The page at "" says"

Webcam Error
Name: NotAllowedError
Message: Permission denied

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
'cam stuff
    Private frontCamera As Boolean = False
    Dim phid As PhoneId
    Dim rp As RuntimePermissions
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 wv As WebView
    Dim wve As WebViewExtras
    Dim wvs As WebViewSettings
    Private ime1 As IME

    Private ActivityParent As JavaObject
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Log("tried to connect")
    Dim jo As JavaObject = wv
    Dim settings As JavaObject = jo.RunMethod("getSettings", Null)
    'jo.RunMethod("SetChrome", Array(wve))
    Dim r As Reflector
    r.Target = settings
    r.RunMethod2("setAllowUniversalAccessFromFileURLs", True, "java.lang.boolean")
 End Sub

Sub Activity_Resume
    For Each permission As String In Array (Starter.rp.Permission_CAMERA)
        wait for Activity_PermissionResult (permission As String, Result As Boolean)
        If Result = False Then
            ToastMessageShow("No permission!", True)
        Log("no Permission")
                If Result = True Then
                End If
                    End If
End Sub

Sub Activity_PermissionResult (Permision As String, Result As Boolean)
    If Permision = Starter.rp.PERMISSION_CAMERA Then
         Activity_PermissionResult (Permision, True)
         Result = True
            End If

End Sub
Sub client_ReceivedSslError(SslErrorHandler1 As SslErrorHandler, SslError1 As SslError)
End Sub

Sub IME1_HeightChanged (NewHeight As Int, OldHeight As Int)
End Sub


Sub AfterChange
    Dim ajo As Panel = Activity
    Dim width As Int = ActivityParent.RunMethod("getMeasuredWidth", Null)
    Dim height As Int = ActivityParent.RunMethod("getMeasuredHeight", Null)
    If width = 0 Or height = 0 Then Return
    ajo.width = width 'update the "activity" width and height
    ajo.height = height
    wv.width = width
    wv.height = height
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

'    the official google vr library documentation recommends to call the Shutdown() method before the activity is destroyed
'    we'll use inline java to ensure that the Shutdown() method is called

 #if java

#End If


Licensed User
I've tried to run that example multiple times and other webrtc example. They all give me the same error:

B4A Version: 8.50
Parsing code. (0.01s)
Building folders structure. (0.04s)
Compiling code. (0.01s)

ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
Generating R file. (0.05s)
Compiling generated Java code. Error
B4A line: 17
End Sub
src\b4a\example\ error: cannot find symbol
public void onPermissionRequest(PermissionRequest request) {
symbol: class PermissionRequest
location: class MyChromeClient

Am I missing a step or a library to this, cause it never compiles for me.
Last edited:


Licensed User
No it wasn't. I was on platform 19 still for some reason. I switch to 28 and my app now works, Awesome. problem solved. I Now have a working Augmented Reality application. Thank you Erel


Licensed User


Licensed User
Sounds like you are using an old SDK Installation.
As far as i know it is no longer compatible and everyone needs to setup a new SDK. Especially when using maven artifacts.

You can find the setup instructions here:
Right Don. Updating my sdk is something I do always in the sdk manager. Updating the platform was just one of the steps I missed. After doing this for so long it becomes repetitive and you sometimes forget certain steps. Thats why its always good to ask questions. Thanks for your help.
Last edited:


Licensed User
Ok had to clean it up a little bit but here is my augmented reality project working in a B4A webview. This is not in a Chrome browser or Firefox or Opera. This is B4a application. So far no issues. Now that this hurdle has been solved. I guess the next thing is to try and get this project as a wrapper in B4a. but my knowledge of creating the library is limited.


Last edited: