title: Android Webview Permission denied error when try to video call
body: <p>I am using a webview to load a url which has a feature to video call. 
  When i try to initiate a video call. I get the following error "Permission denied. Please refresh the page and allow access to your camera and microphone" .</p>
  
  <p><a href="https://i.stack.imgur.com/qEnif.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qEnif.jpg" alt="Permission Denied"></a></p>
  
  <p>If i give android runtime permission of CAMERA and RECORD_AUDIO. The video call will be initiated and the video will be transmitted to the computer also. But on the mobile side, I cannot view my video as well as the receiver's video. It shows the getDefaultVideoPoster() only.</p>
  
  <p><a href="https://i.stack.imgur.com/0fcvq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0fcvq.jpg" alt="enter image description here"></a></p>
  
  <p>I have already tried using WebChromeClient and WebViewClient but still no luck.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    private WebView webView;
  
      webView = findViewById(R.id.webview);
      WebSettings webSettings = webView.getSettings();
      webSettings.setJavaScriptEnabled(true);
      webSettings.setDomStorageEnabled(true);
      webSettings.setSaveFormData(true);
      webSettings.setSupportZoom(false);
      webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
      webSettings.setPluginState(WebSettings.PluginState.ON);
      webSettings.setUseWideViewPort(true);
      webSettings.setLoadWithOverviewMode(true);
  
  
      webView.setWebViewClient(new MyWebViewClient());
      webView.setWebChromeClient(new WebChromeClient() {
          @Override
          public void onPermissionRequest(final PermissionRequest request) {
              myRequest = request;
  
              for (String permission : request.getResources()) {
                  switch (permission) {
                      case "android.webkit.resource.AUDIO_CAPTURE": {
                          askForPermission(request.getOrigin().toString(), Manifest.permission.RECORD_AUDIO, MY_PERMISSIONS_REQUEST_RECORD_AUDIO);
                          break;
                      }
                      case Manifest.permission.RECORD_AUDIO: {
                          askForPermission(request.getOrigin().toString(), Manifest.permission.RECORD_AUDIO, MY_PERMISSIONS_REQUEST_RECORD_AUDIO);
                          break;
                      }
                      case Manifest.permission.CAMERA: {
                          askForPermission(request.getOrigin().toString(), Manifest.permission.CAMERA, MY_PERMISSIONS_REQUEST_CAMERA);
                          break;
                      }
                  }
              }
          }
  
          @Nullable
          @Override
          public Bitmap getDefaultVideoPoster() {
              Log.i(TAG, "getDefaultVideoPoster");
              return drawableToBitmap(getResources().getDrawable( R.drawable.ic_temperature));
              //return super.getDefaultVideoPoster();
          }
  
          @Override
          public void onShowCustomView(View view, CustomViewCallback callback) {
              super.onShowCustomView(view, callback);
              Log.i(TAG, "onShowCustomView");
              if (view instanceof FrameLayout){
                  FrameLayout frame = (FrameLayout) view;
                  if (frame.getFocusedChild() instanceof VideoView){
                      VideoView video = (VideoView) 
                      frame.getFocusedChild();
                      frame.removeView(video);
                      video.start();
                  }
              }
          }
      });
  </code></pre>