mgks / Android-SmartWebView

A simple use webview integrated w/ native features to help create most advanced hybrid applications.
https://mgks.dev/smart-webview
MIT License
570 stars 278 forks source link

The Webview is not allowing Camera permission for any site #221

Open surajgirhepunje opened 3 years ago

surajgirhepunje commented 3 years ago

When I integrate the https://webcamtests.com/ in webview and checked the permission settings as well. Still got error. Please check screenshot. WhatsApp Image 2021-04-02 at 6 22 33 PM WhatsApp Image 2021-04-02 at 6 23 12 PM

ahtoh68 commented 3 years ago

In the MainActyvity file inside asw_view.setWebChromeClient (new WebChromeClient () { add:

@Override
public void onPermissionRequest(final PermissionRequest request) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
      if (!check_permission(3)) {
      ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.CAMERA}, file_perm);
      }
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this)
    .setTitle("Allow Permission to camera")
    .setPositiveButton("Allow", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        dialog.dismiss();
        request.grant(request.getResources());
        Log.d(TAG, "Granted");
        }
    })
    .setNegativeButton("Deny", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        dialog.dismiss();
        request.deny();
        Log.d(TAG, "Denied");
        }
    });
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
  }
}
GeckoLee commented 3 years ago

Thank you! This change allows camera usage again.

bishu commented 3 years ago

@ahtoh68 It is not working for me. I am using the latest SmartWebView Please anyone kindly help with the camera issue.

VarshaMenon commented 2 years ago

Same issue with me also. It was working perfectly before. Recently came to know that webview isn't supporting camera and audio permissions. Can anyone tell me the reason and possible solutions. Thanks in advance.