Неизвестная ошибка использования камеры permission denied

Данный код отлично работает с камерой в версиях андроида ниже 6.0. Но с версией 6.0 выдаёт ошибку в использование камеры. Как можно исправить эту ошибку?

public class MainActivity extends AppCompatActivity {
private final String TAG = this.getClass().getName();

ImageView ivCamera, ivGallery, ivUpload, ivImage;

CameraPhoto cameraPhoto;
GalleryPhoto galleryPhoto;

final int CAMERA_REQUEST = 13323;
final int GALLERY_REQUEST = 22131;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    cameraPhoto = new CameraPhoto(getApplicationContext());
    galleryPhoto = new GalleryPhoto(getApplicationContext());

    ivImage = (ImageView)findViewById(R.id.ivImage);
    ivCamera = (ImageView)findViewById(R.id.ivCamera);
    ivGallery = (ImageView)findViewById(R.id.ivGallery);
    ivUpload = (ImageView)findViewById(R.id.ivUpload);

    ivCamera.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {



            try {
                startActivityForResult(cameraPhoto.takePhotoIntent(), CAMERA_REQUEST);
                cameraPhoto.addToGallery();

            } catch (IOException e) {
                e.printStackTrace();
                Toast.makeText(getApplicationContext(),
                        "Something Wrong while taking photos", Toast.LENGTH_SHORT).show();
            }
        }
    });

    ivGallery.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivityForResult(galleryPhoto.openGalleryIntent(), GALLERY_REQUEST);
        }
    });

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(resultCode == RESULT_OK){
        if(requestCode == CAMERA_REQUEST){
            String photoPath = cameraPhoto.getPhotoPath();
            try {
                Bitmap bitmap = ImageLoader.init().from(photoPath).requestSize(512, 512).getBitmap();
                ivImage.setImageBitmap(bitmap);
            } catch (FileNotFoundException e) {
                Toast.makeText(getApplicationContext(),
                        "Something Wrong while loading photos", Toast.LENGTH_SHORT).show();
            }

        }
        else if(requestCode == GALLERY_REQUEST){
            Uri uri = data.getData();

            galleryPhoto.setPhotoUri(uri);
            String photoPath = galleryPhoto.getPath();
            try {
                Bitmap bitmap = ImageLoader.init().from(photoPath).requestSize(512, 512).getBitmap();
                ivImage.setImageBitmap(bitmap);
            } catch (FileNotFoundException e) {
                Toast.makeText(getApplicationContext(),
                        "Something Wrong while choosing photos", Toast.LENGTH_SHORT).show();
            }
        }
    }
  }
 }

Android Manifest

Android Monitor

Main Activity

I have created WebView Activity and loading https://web.doar.zone/coronavirus

This URL required Camera permission which I had taken Runtime Permission in Android.

Here is the full code of MainActivity.java:

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";

    Context context;

    ActivityMainBinding binding;

    private String url = "https://web.doar.zone/coronavirus";

    @Override
    protected void onResume() {
        super.onResume();
        checkCameraPermission();
    }

    private void checkCameraPermission() {
        int writeExternalStorage = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
        if (writeExternalStorage != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 1001);
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode == 1001) {
            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                //Do your stuff
                openWebView();
            } else {
                checkCameraPermission();
            }
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        context = getApplicationContext();

        openWebView();
    }

    @SuppressLint("SetJavaScriptEnabled")
    void openWebView() {

        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

        final NetworkInfo networkInfo;
        if (connectivityManager != null) {
            networkInfo = connectivityManager.getActiveNetworkInfo();
            if (networkInfo != null && networkInfo.isConnectedOrConnecting()) {
                binding.internetTextView.setVisibility(View.INVISIBLE);
                binding.webView.setVisibility(View.VISIBLE);
                //binding.webView.getSettings().setUserAgentString("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.3");
                binding.webView.getSettings().setJavaScriptEnabled(true);
                binding.webView.getSettings().setUseWideViewPort(true);
                binding.webView.getSettings().setDomStorageEnabled(true);
                binding.webView.setInitialScale(1);
                binding.webView.setWebChromeClient(new MyWebChromeClient());
                binding.webView.setWebViewClient(new WebViewClient() {

                    @Override
                    public boolean shouldOverrideUrlLoading(WebView webview, String url) {
                        Uri uri = Uri.parse(url);
                        if (uri.getScheme().contains("whatsapp") || uri.getScheme().contains("tel")) {
                            try {
                                Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
                                if (intent.resolveActivity(getPackageManager()) != null)
                                    startActivity(intent);
                                return true;
                            } catch (URISyntaxException use) {
                                Log.e("TAG", use.getMessage());
                            }
                        } else {
                            webview.loadUrl(url);
                        }

                        return true;
                    }

                    @Override
                    public void onPageFinished(WebView view, String url) {
                        super.onPageFinished(view, url);
                    }
                });
                binding.webView.loadUrl(url);
            } else {

                binding.internetTextView.setVisibility(View.VISIBLE);
                binding.buttonTryAgain.setVisibility(View.VISIBLE);
                binding.webView.setVisibility(View.INVISIBLE);

                Toast.makeText(context, "Connect to Internet and Refresh Again", Toast.LENGTH_LONG).show();
            }
        } else {
            binding.internetTextView.setVisibility(View.VISIBLE);
            binding.buttonTryAgain.setVisibility(View.VISIBLE);
            binding.webView.setVisibility(View.INVISIBLE);

            Toast.makeText(context, "Connect to Internet and Refresh Again", Toast.LENGTH_LONG).show();
        }
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                if (binding.webView.canGoBack()) {
                    binding.webView.goBack();
                } else {
                    finish();
                }
                return true;
            }

        }
        return super.onKeyDown(keyCode, event);
    }

    class MyWebChromeClient extends WebChromeClient {

        MyWebChromeClient() {
            // TODO Auto-generated constructor stub
            binding.pb.setProgress(0);
        }

        @Override
        public void onPermissionRequest(final PermissionRequest request) {
            super.onPermissionRequest(request);
            //request.grant(request.getResources());
        }

        public void onProgressChanged(WebView view, int progress) {
            if (progress < 100  /* && pBar.getVisibility() == View.VISIBLE*/) {
                binding.pb.setVisibility(View.VISIBLE);
            }
            binding.pb.setProgress(progress);
            if (progress == 100) {
                binding.pb.setVisibility(View.GONE);
            }
        }
    }
}

Now I am getting error as below When I comment this line:

request.grant(request.getResources());

enter image description here

And If I uncomment this line then I am getting:

 java.lang.IllegalStateException: Either grant() or deny() has been already called.
    at org.chromium.android_webview.permission.AwPermissionRequest.c(PG:3)
    at org.chromium.android_webview.permission.AwPermissionRequest.b(PG:1)
    at Cn.grant(PG:8)
    at com.example.webviewapp.MainActivity$MyWebChromeClient.onPermissionRequest(MainActivity.java:164)
    at org.chromium.android_webview.AwContents.onPermissionRequest(PG:8)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:326)
    at android.os.Looper.loop(Looper.java:181)
    at android.app.ActivityThread.main(ActivityThread.java:7078)
2020-04-29 11:52:21.813 4943-4943/com.example.webviewapp W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)

Any Help?

I have created WebView Activity and loading https://web.doar.zone/coronavirus

This URL required Camera permission which I had taken Runtime Permission in Android.

Here is the full code of MainActivity.java:

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";

    Context context;

    ActivityMainBinding binding;

    private String url = "https://web.doar.zone/coronavirus";

    @Override
    protected void onResume() {
        super.onResume();
        checkCameraPermission();
    }

    private void checkCameraPermission() {
        int writeExternalStorage = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
        if (writeExternalStorage != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 1001);
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode == 1001) {
            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                //Do your stuff
                openWebView();
            } else {
                checkCameraPermission();
            }
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        context = getApplicationContext();

        openWebView();
    }

    @SuppressLint("SetJavaScriptEnabled")
    void openWebView() {

        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

        final NetworkInfo networkInfo;
        if (connectivityManager != null) {
            networkInfo = connectivityManager.getActiveNetworkInfo();
            if (networkInfo != null && networkInfo.isConnectedOrConnecting()) {
                binding.internetTextView.setVisibility(View.INVISIBLE);
                binding.webView.setVisibility(View.VISIBLE);
                //binding.webView.getSettings().setUserAgentString("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.3");
                binding.webView.getSettings().setJavaScriptEnabled(true);
                binding.webView.getSettings().setUseWideViewPort(true);
                binding.webView.getSettings().setDomStorageEnabled(true);
                binding.webView.setInitialScale(1);
                binding.webView.setWebChromeClient(new MyWebChromeClient());
                binding.webView.setWebViewClient(new WebViewClient() {

                    @Override
                    public boolean shouldOverrideUrlLoading(WebView webview, String url) {
                        Uri uri = Uri.parse(url);
                        if (uri.getScheme().contains("whatsapp") || uri.getScheme().contains("tel")) {
                            try {
                                Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
                                if (intent.resolveActivity(getPackageManager()) != null)
                                    startActivity(intent);
                                return true;
                            } catch (URISyntaxException use) {
                                Log.e("TAG", use.getMessage());
                            }
                        } else {
                            webview.loadUrl(url);
                        }

                        return true;
                    }

                    @Override
                    public void onPageFinished(WebView view, String url) {
                        super.onPageFinished(view, url);
                    }
                });
                binding.webView.loadUrl(url);
            } else {

                binding.internetTextView.setVisibility(View.VISIBLE);
                binding.buttonTryAgain.setVisibility(View.VISIBLE);
                binding.webView.setVisibility(View.INVISIBLE);

                Toast.makeText(context, "Connect to Internet and Refresh Again", Toast.LENGTH_LONG).show();
            }
        } else {
            binding.internetTextView.setVisibility(View.VISIBLE);
            binding.buttonTryAgain.setVisibility(View.VISIBLE);
            binding.webView.setVisibility(View.INVISIBLE);

            Toast.makeText(context, "Connect to Internet and Refresh Again", Toast.LENGTH_LONG).show();
        }
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                if (binding.webView.canGoBack()) {
                    binding.webView.goBack();
                } else {
                    finish();
                }
                return true;
            }

        }
        return super.onKeyDown(keyCode, event);
    }

    class MyWebChromeClient extends WebChromeClient {

        MyWebChromeClient() {
            // TODO Auto-generated constructor stub
            binding.pb.setProgress(0);
        }

        @Override
        public void onPermissionRequest(final PermissionRequest request) {
            super.onPermissionRequest(request);
            //request.grant(request.getResources());
        }

        public void onProgressChanged(WebView view, int progress) {
            if (progress < 100  /* && pBar.getVisibility() == View.VISIBLE*/) {
                binding.pb.setVisibility(View.VISIBLE);
            }
            binding.pb.setProgress(progress);
            if (progress == 100) {
                binding.pb.setVisibility(View.GONE);
            }
        }
    }
}

Now I am getting error as below When I comment this line:

request.grant(request.getResources());

enter image description here

And If I uncomment this line then I am getting:

 java.lang.IllegalStateException: Either grant() or deny() has been already called.
    at org.chromium.android_webview.permission.AwPermissionRequest.c(PG:3)
    at org.chromium.android_webview.permission.AwPermissionRequest.b(PG:1)
    at Cn.grant(PG:8)
    at com.example.webviewapp.MainActivity$MyWebChromeClient.onPermissionRequest(MainActivity.java:164)
    at org.chromium.android_webview.AwContents.onPermissionRequest(PG:8)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:326)
    at android.os.Looper.loop(Looper.java:181)
    at android.app.ActivityThread.main(ActivityThread.java:7078)
2020-04-29 11:52:21.813 4943-4943/com.example.webviewapp W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)

Any Help?

Contents

  • Setting up your camera
  • Troubleshooting and errors
  • Browser-specific camera help
  • More camera troubleshooting for Mac & PC

Setting up your camera

To set up your computer’s camera or webcam, please visit Device Setup on your Check-In page. For the best experience, we recommend using a Chrome browser.

Check in page highlighting Device Setup step to be completed

On the first page, you’ll be prompted to ‘Allow’ Kira Talent (app.kiratalent.com) to access your camera and microphone. Please click ‘Allow’ and ‘Remember’ in every prompt that appears.

In Chrome, Opera, and Edge — click ‘Allow’ in the prompt coming from the lock icon to the left of your address bar.

The device permissions prompt in Chrome, Opera, or Edge with "Allow" and "Block" options

In Firefox, click ‘Remember this decision’ and ‘Allow’ in the prompt coming from the camera icon to the left of your address bar.

The device permissions prompt in Firefox with "Allow" and "Don't Allow" options

Once you’ve successfully allowed Kira to access your camera and microphone, you should be able to see yourself on the screen.

Please see our Microphone Setup & Troubleshooting article for information about setting up your microphone.


Troubleshooting & errors

Having issues with your camera? Please see the tips below.

‘We don’t have access to your camera or microphone’

Click «Show more’, and refer to the specific error below.

Error stating "we don't have access to your camera or microphone"

NotAllowedError: Permission denied

Error showing'NotAllowed' under the'Show more' button

This error message occurs when the Kira platform has been denied access to your camera or microphone, either for your current browsing session or globally across your computer.

In Chrome, Opera, and Edge, ensure your camera and microphone options under the lock icon are changed to ‘Allow’ instead of ‘Block’. Refresh the page, or start a new browser session.

Menu in Chrome, Opera, and Edge where device permissions are changed from Block to Allow

In Firefox, click the small x’s beside ‘Blocked Temporarily’ for your camera and microphone. Refresh the page, or start a new browser session.

Menu in Firefox where a'Blocked Temporarily' permission can be removed

If this didn’t work, please double-check your camera and microphone settings in your browser. Ensure that the ‘Ask before accessing’ option is turned on, and that the Kira Talent site is not under the blocked list. 

Chrome settings where blocked sites can be removed, and choices about allowing access to camera and microphones can be made

NotFoundError: Requested device not found

Error showing'NotFound' under the'Show more' button

If you’re seeing this error, your camera and/or microphone cannot be found by your browser. This could mean they aren’t working properly, they’re being used somewhere else, or they don’t exist. If you don’t have a camera or microphone, please review the device requirements for Kira. 

If your camera and microphone work with other sites, ensure all other applications and browsers that could be using them are closed. If the issue persists, please try again using incognito Chrome.

NotReadableError: Concurrent mic process limit

Error showing'NotReadable' under the'Show more' button

This error message typically indicates an issue with multiple camera and/or microphone options in Firefox. If this error persists for you, we recommend simply trying another browser.

OvercontrainedError

This error typically means that your camera and/or microphone is being used in too many places at once. Please close everything down, and try to complete a Device Setup again in an incognito Chrome browser.

‘We can’t detect your camera or microphone’

Error stating "we can't detect your camera or microphone"

This error message indicates that the Kira platform cannot detect or use your camera and/or microphone. To double-check you have the equipment required to complete Kira, please refer to our Supported Browsers & Devices article. If the issue persists, please try again using incognito Chrome.

‘Something went wrong while accessing your camera and microphone.’

Error stating "something went wrong while accessing your camera or microphone"

This error message could indicate that there are detectable hardware issues coming from your operating system, browser, or webpage. If the issue persists, this may be a browser-specific or computer-specific issue, or you could have third party extensions that are blocking the Kira platform from accessing our camera or microphone. To double-check you have the equipment required to complete Kira, please refer to our Supported Browsers & Devices article. If the issue persists, please try again using incognito Chrome.

‘Please ensure your camera is connected and access is allowed’

If you’re receiving this error in a live Kira interview, the platform doesn’t have access to your camera.

First, make sure your camera is working in other applications. Then, close your browser, re-open your unique link, and allow the Kira platform access to your camera again.

If that doesn’t work, try selecting another option from the dropdown, using a new browser, or restarting your computer. We also recommend going through another Device Setup on your Check-In page.


Browser-specific help

  • Chrome
  • Firefox
  • Edge
  • Opera

If you’re not using any of the browsers above, please refer to our Supported Browsers article.


Camera troubleshooting tips for Mac

  1. Make sure that all other programs that utilize the camera, such as Photo Booth and Facetime, are closed (including Zoom on another browser)
  2. Restart your computer, and start fresh with the «Setting up your camera» steps above.
  3. Check if the camera works in a Mac app, such as Photo Booth or Facetime, or an online webcam test.
  4. If your camera does not work in any application, contact Apple Support.
  5. If your camera works elsewhere and still not in Kira, please contact support@kiratalent.com.

Note: If you are on Mac OS 10.14 Mojave and are still having difficulty accessing the camera, check your operating system permissions to confirm that Kira has access to the camera. Visit your System Preferences, click Security & Privacy, click Camera, and ensure your specific browsers have been allowed to use your camera.

System preferences modal on a Mac
Security and Privacy page within System Preferences on a Mac


Camera troubleshooting tips for PC

  1. Make sure that all other programs that utilize the camera are not using the camera or are closed.
  2. Restart your computer, and start fresh with the «Setting up your camera» steps above.
  3. Test your camera with an external online webcam test.
  4. If your camera does not work in any application, visit your device’s support and downloads page to update the camera driver:
    • Logitech
    • Dell
    • Lenovo
    • HP
    • ASUS
    • Samsung
    • Sony (PC)
  5. If your camera works elsewhere and still not in Kira, please contact support@kiratalent.com.

Note: Windows 10 has a privacy feature that may block Kira from using the camera. Learn more about this feature and how to allow Kira access to your camera.

There are two types of permission.

Normal permission (does not need to ask from user)
Dangerous permissions (need to be asked)

В вашем манифесте есть 3 опасное разрешение.

<uses-permission android:name = "android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name = "android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name = "android.permission.CAMERA" />

См. нормальное и опасное разрешение в документации Android.

Вы должны ввести код для запроса разрешения.

Спроси разрешение

 ActivityCompat.requestPermissions(MainActivity.this,
                    new String[]{Manifest.permission.CAMERA},
                    1);

Обработайте результат

@Override
public void onRequestPermissionsResult(int requestCode,
                                       String permissions[], int[] grantResults) {
    switch (requestCode) {
        case 1: {

          // If request is cancelled, the result arrays are empty.
          if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {

                // permission was granted, yay! Do the
                // contacts-related task you need to do.          
            } else {

                // permission denied, boo! Disable the
                // functionality that depends on this permission.
                Toast.makeText(MainActivity.this, "Permission denied", Toast.LENGTH_SHORT).show();
            }
            return;
        }

        // other 'case' lines to check for other
        // permissions this app might request
    }
}

Кончик:

Если вы не хотите много писать для запроса разрешения в разных классах. Воспользуйтесь какой-нибудь библиотекой. Нравиться

  • https://github.com/tbruyelle/RxPermissions
  • https://github.com/Karumi/Dexter

Я использую RxPermissions. Которые обеспечивают простую функцию.

rxPermissions
    .request(Manifest.permission.CAMERA)
    .subscribe(granted -> {
        if (granted) { // Always true pre-M
           // I can control the camera now
        } else {
           // Oups permission denied
        }
    });

См. конфигурация для RxPermission

Более подробная информация: https://developer.android.com/training/permissions/requesting.html

  • Home
  • Forum
  • The Ubuntu Forum Community
  • Ubuntu Official Flavours Support
  • Hardware
  • [ubuntu] WEBCAM: «open /dev/video0: Permission denied»

  1. Arrow WEBCAM: «open /dev/video0: Permission denied»

    I’ve run into a problem while installing my webcam for use in amsn and skype etc.

    Part of the problem perhaps is that its one of the awkward Ricoh Motion-Eye webcams discussed in detail [here].
    Specifically a VGP-VCC2 in a Sony Vaio VGN-SZ3XWP.

    Code:

    user@host:~$ lsusb
    Bus 005 Device 003: ID 05ca:1830 Ricoh Co., Ltd Visual Communication Camera VGP-VCC2

    I suspect I’ve installed the driver correctly as I’ve created /dev/video0 and I can get the package ‘webcam’ to take a snapshot and save it via SSH on localhost. But aMSN, Cheese and Camorama won’t detect it. (I’ve installed it as described by epvipas in post #55, on kernel 2.6.27-11-generic).

    Strangely, webcam without admin rights returns…

    Code:

    user@host:~$ webcam
    reading config file: /home/user/.webcamrc
    v4l2: open /dev/video0: Permission denied
    v4l2: open /dev/video0: Permission denied
    v4l: open /dev/video0: Permission denied
    no grabber device available

    However, with root access works fine…

    Code:

    user@host:~$ sudo webcam
    reading config file: /home/user/.webcamrc
    video4linux webcam v1.5 - (c) 1998-2002 Gerd Knorr
    grabber config:
      size 320x240 [none]
      input (null), norm (null), jpeg quality 75
      rotate=0, top=0, left=5, bottom=240, right=320
    ssh config [ftp]:
      user@localhost:/home/user/cam
      uploading.jpeg => webcam2.jpeg

    Stanger still, aMSN, Cheese and Camorama still won’t conect to the webcam when run as root.

    eg. sudo camorama
    Error Dialog: Error (camorama)
    Msg: Could not connect to the video device (/dev/video0). Please check the connection.

    Has anyone experience of this of can offer a solution?
    Thanks.

    Last edited by switchseven; February 3rd, 2009 at 04:24 AM.


  2. Re: WEBCAM: «open /dev/video0: Permission denied»

    Hello,

    I solved the problem. You must give to the user (you) permission for use video devices. Go to System > Administration > Users and Groups. Unlock and select your username. In user privileges, you must enable the line «Capture video from TV or webcams, and use 3d acceleration«, log off and log in.

    I hope that help you. Greetings,

    Pablo.


  3. Re: WEBCAM: «open /dev/video0: Permission denied»

    after days of pulling my hair out your solution made my skype work…thanks very much.


  4. Re: WEBCAM: «open /dev/video0: Permission denied»

    Quote Originally Posted by pnavarrc
    View Post

    Hello,

    I solved the problem. You must give to the user (you) permission for use video devices. Go to System > Administration > Users and Groups. Unlock and select your username. In user privileges, you must enable the line «Capture video from TV or webcams, and use 3d acceleration«, log off and log in.

    I hope that help you. Greetings,

    Pablo.

    How do i do this from the command line?

    Thanks Markp1989?

    Desktop:i7 875k|4gb OCZ platinum ddr3 2000|Evga P55 LE mobo|OCZ RevoDrive 50gb|ATI 5850 Black Edition|Silverstone FT02|corsair tx650
    Portable: 13″ Macbook Pro 2.8ghz i7 16gb RAM | Asus EEE TF101 | Samsung Galaxy S2


  5. Re: WEBCAM: «open /dev/video0: Permission denied»

    Use usermod to ad the group video
    man usermod

    Code:

    sudo usermod -a -G group user

    After that logout and back in and it will work.


  6. Re: WEBCAM: «open /dev/video0: Permission denied»

    It doesn’t work for me!! I have

    $ ls -l /dev/video0
    crw-rw-rw-+ 1 root video 81, 0 2009-11-25 13:45 /dev/video0
    $ grep video /etc/group
    video:44:dori,marci,apu
    $ whoami
    apu

    $ xawtv -c /dev/video0
    This is xawtv-3.95.dfsg.1, running on Linux/x86_64 (2.6.31-15-generic)
    xinerama 0: 1680×1050+0+0
    WARNING: No DGA direct video mode for this display.
    /dev/video0 [v4l2]: no overlay support
    v4l-conf had some trouble, trying to continue anyway
    v4l2: open /dev/video0: Enged�ly megtagadva
    v4l2: open /dev/video0: Enged�ly megtagadva
    v4l: open /dev/video0: Enged�ly megtagadva
    no video grabber device available

    (Enged�ly megtagadva = Permission denied)


Bookmarks

Bookmarks


Posting Permissions

Я хотел бы использовать веб-камеру моего старого ноутбука (мой ноутбук — Packard Bell EasyNote MX37), чтобы делать потоковое видео.

Я пытаюсь сделать это потоковое видео через VLC, следуя этому руководству от Ubuntu 14.04 LTS.

К сожалению, я застреваю, когда я применяю эту командную строку:

cvlc v4l2:///dev/video0 :v4l2-standard= :input-slave=alsa://hw:0,0
:live-caching=300
:sout="#transcode{vcodec=WMV2,vb=800,acodec=wma2,ab=128,channels=2,samplerate=44100}:http{dst=:8080/stream.wmv}"

В самом деле, я получаю это сообщение об ошибке:

VLC media player 2.1.6 Rincewind (revision 2.1.6-0-gea01d28)
[0x19....] dummy interface: using the dummy interface module...
[0x7f1................] main access out error: socket bind error (Permission denied)
[0x7f1................] main access out error: socket bind error (Permission denied)
[0x7f1................] main access out error: cannot create socket(s) for HTTP host
[0x7f1................] access_output_http access out error: cannot start HTTP server
[0x7f1................] stream_out_standard stream out error: no suitable sout access module for 'http/asf://:8080/stream.wmv'
[0x7f1................] main stream output error: stream chain failed for 'transcode{vcodec=WMV2,vb=800,acodec=wma2,ab=128,channels=2,samplerate=44100}:http{dst=:8080/stream.wmv}'
[0x7f1................] main input error: cannot start stream output instance, aborting

Большое спасибо за вашу помощь!

PS: Цель состоит в том, чтобы следить за моей парковкой.

I want to get and storage a photo from an android camera. This is the code:

public void avviaFotocamera(View v){
        this.launchCamera();
    }

    private void launchCamera() {
        try {
            mOutputFile = new File(getExternalStorageDirectory(),  "temp.jpg");
            Intent intentCamera = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            intentCamera.putExtra(MediaStore.EXTRA_OUTPUT,
                    Uri.fromFile(mOutputFile));
            startActivityForResult(intentCamera, CAMERA_REQUEST);
        }   catch (Exception e) {
            Toast t = Toast.makeText(this, "Si è verificato un errore durante l'acquisizione dell'immagine:n" + e.toString(), Toast.LENGTH_LONG);
            t.show();
        }
    }

        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {

            if(requestCode == CAMERA_REQUEST) {
                try {
                    Bitmap datiFoto = android.provider.MediaStore.Images.Media.getBitmap(this.getContentResolver(),
                                      Uri.fromFile(mOutputFile));
                    saveBitmap(datiFoto);
                    mOutputFile.delete();
                }   catch (Exception e) {
                    Toast t = Toast.makeText(this, "Si è verificato un errore durante l'acquisizione dell'immagine:n" + e.toString(), Toast.LENGTH_LONG);
                    t.show();
                }
            }
        }

    private void saveBitmap(Bitmap datiFoto) {
        try {
            //Nome del file da assegnare all'immagine
            final String fileName = "prova.jpg";
            FileOutputStream out = new FileOutputStream(getExternalStorageDirectory ()+fileName);
            datiFoto.compress(Bitmap.CompressFormat.JPEG, 90, out);
        }   catch (Exception e) {
            Toast t = Toast.makeText(this, "Si è verificato un errore durante il salvataggio dell'immagine:n" + e.toString(), Toast.LENGTH_LONG);
            t.show();
            e.printStackTrace();
        }
    }

however i get this error: java.io.FileNotFoundException: /prova.jpg: open failed: EACCES (Permission denied).
This is the manifest where i add all the required permissions:

 <uses-sdk
        android:maxSdkVersion="22"
        android:minSdkVersion="15"
        android:targetSdkVersion="15" />

    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:maxSdkVersion="22" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission
        android:name="android.permission.READ_EXTERNAL_STORAGE"
        android:maxSdkVersion="22" />
    <uses-permission android:name="android.permission.SET_DEBUG_APP" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-feature android:name="android.hardware.camera"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="com.javapapers.android.maps.path.permission.MAPS_RECEIVE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />  

How can i fix it??

First Option you have regarding permissions is to go to the android settings of that specific application and grant it all permissions it requires from there. Second option you have is to check whether that permission is required during runtime and request for permissions the app needs or an even better approach is to ask for a permission when a feature is run that requires that permission.

Well go through some code that ask for app permissions when an activity opens. But you can modify that code to ask for permission when a feature such as taking camera is required.

And another thing is that some permissions such as Internet are granted automatically by the system therefore you don’t need to ask for it. However You will need to ask for some explicitly.

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CAMERA"/>  

The above shows the permissions declared right above the opening application tag in the AndroidManifest.

    public boolean hasFineLocationPermission(){
        if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED){
            return true;
        }
        else{
            return false;
        }
    }

    public boolean hasExternalStoragePermission(){
        if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
            return true;
        }
        else{
            return false;
        }
    }

public boolean hasLocationForegroundService(){
    if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.FOREGROUND_SERVICE) == PackageManager.PERMISSION_GRANTED){
        return true;
    }
    else{
        return false;
    }
}



public boolean hasReadPhoneStatePermission(){
    if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED){
        return true;
    }
    else{
        return false;
    }
}

public boolean hasCameraPermission(){
    if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED){
        return true;
    }
    else{
        return false;
    }
}

public boolean hasAccessNetworkState(){
    if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_NETWORK_STATE) == PackageManager.PERMISSION_GRANTED){
        return true;
    }
    else{
        return false;
    }
}

We have some functions above. What all the functions do is basically check if a certain permission is granted. If it is return true therefore there is no need to ask for that permission. If not return false therefore well ask for that permission in a bit. For example:

if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED){
return true;
}

This checks If we have access to the camera and if we do it returns True and if not it will return false as shown in the function hasCameraPermission()

Now we can check that all permissions are granted using the function below:

public void getApplicationPermissions(){

    List<String> listPermissionsNeeded = new ArrayList<>();
    if (!hasFineLocationPermission()){

        listPermissionsNeeded.add(Manifest.permission.ACCESS_BACKGROUND_LOCATION);

    }

    if (!hasExternalStoragePermission()){

        listPermissionsNeeded.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);

    }

    if (!hasLocationForegroundService()){
        listPermissionsNeeded.add(Manifest.permission.ACCESS_FINE_LOCATION);

    }
    if (!hasReadPhoneStatePermission()){
        listPermissionsNeeded.add(Manifest.permission.READ_PHONE_STATE);
    }

    if (!hasCameraPermission()){
        listPermissionsNeeded.add(Manifest.permission.CAMERA);
    }

    if (!hasAccessNetworkState()){
        listPermissionsNeeded.add(Manifest.permission.ACCESS_NETWORK_STATE);
    }

    Log.i("listPermissionsNeeded", String.valueOf(listPermissionsNeeded));

    if (!listPermissionsNeeded.isEmpty()){
        ActivityCompat.requestPermissions(this,listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]),0);
    }
    else{
        Toast.makeText(this,"All Permissions Required Are Granted",Toast.LENGTH_SHORT).show();
    }

}

The code above first declares a list List<String> listPermissionsNeeded = new ArrayList<>(); of type String

Then checks if:

if (!hasCameraPermission()){
            listPermissionsNeeded.add(Manifest.permission.CAMERA);
        } 

Meaning: If Permission to camera has not been granted add that permission to the list by adding Manifest.permission.CAMERA

If our permissionsList is Empty we’ll just show the user a toast. However If it does have some permissions we Call the function ActivityCompat.requestPermissions() passing in context,our list and an identifier which in this case is 0:

if (!listPermissionsNeeded.isEmpty()){
    ActivityCompat.requestPermissions(this,listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]),0);
}
else{
    Toast.makeText(this,"All Permissions Required Are Granted",Toast.LENGTH_SHORT).show();
} 

When that requestPermissions is called another android method is called which is onRequestPermissionsResult(). We implement it as below:

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);

        if(requestCode=0){
         for (int i=0;i<grantResults.length;i++){
            if (grantResults[i] == -1){
                getApplicationPermissions();

            }
        }

        }

    }

The the request Code will be 0 and the grantResults will be the list we passed in the function: ActivityCompat.requestPermissions(this,listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]),0);

When a permission is rejected by the user you will get back a value of -1 in the grantResult. All I do in that function is loop through my grantResults and search for any permission that has been rejected and if there is a permission that has been rejected, I ask for it again and again and again. That is terrible for user experience. But you get the point.

Finally We need to check whether the version of Android being used is Android Marshmallow Api Level 23. From what I got, below android 6.0 You can get all permissions as long as you declare it in the Manifest, But starting From 6.0 and upwards You need to ask for the permissions. This way you can avoid a crash in api levels below that. Am not 100% on this, I found conflicting info on this, but settled for that, somebody can correct me there.

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
            getApplicationPermissions();

        }

Hope I’ve not confused you. If you have any questions u can ask or I can send the github link housing that so that u can see how all the code joins up, i.e. if you need it.

All Code was written in Java.

PC Repair and Driver Updater
Recommended for Fixing Issues and Updating Drives on Windows PC. Trusted by Millions.

Facebook Live won’t work and Chrome browser says camera and microphone access was blocked but it isn’t and won’t work. In this post, learn how to fix it.

facebook live Camera Access Denied

Lots of users reporting on the internet that whenever they trying to go live on Facebook, they seeing an error messages which reads:

Camera permission denied

You have blocked camera access. To go live, please update your browser settings to allow access. Try Again

Majority of users also reported that, they’re using the latest version of the Chrome browser, uninstalled and reinstalled it and still unable to fix the issue. So, the question is how to fix this issue?

After reading the error message it seems like this error is related to Chrome permission and we have to tweak permission for Camera and Microphone.

In this blog post, we come up with two solutions which you want to can use to fix the issue. The method includes:

  • Chrome Permission Settings
  • Windows 10 Permission Settings

Let’s start with first method:

Chrome Permission Settings

After you visit facebook.com, click on the View this site information (Lock) icon available at the starting of the address bar.

Here, you need to make sure Permission for both Camera and Microphone are set to Allow and not Ask (default) and Blocked.

allow permissions

In ask it’s set to Allow already, change it to Block.

reload

Reload the tab to apply the changes and then following the same procedure again, set it Allow.

After doing this, the error should fix the issue. In case, error message still appears, then it’s because of Windows 10 Permission settings. If you’re using Windows 10, then try the next method.

Windows 10 Permission Settings

Sometimes “Camera Access Denied” error appear because Camera and Microphone permissions are disabled in Windows 10 Settings app. Here’s how you can enable it:

Launch Settings app in Windows 10 and then select Privacy.

Here, on the left pane, you need to head over to App permissions section and then switch to Camera tab.

windows 10 camera permissions

After that, on the right side, you need to make sure that “Allow apps to access your camera” permission is ON. If not, move the slide to ON position.

Similarly, switch to Microphone tab and turn the “Allow apps to access your Microphone.”

After making changes relaunch Chrome browser and this time, you will be able to go live without any error message.

Use Chrome in Beta Channel

If above discussed methods, fails to fix the issue, then issue could be from Chrome browser side. Some users suggested they download Chrome in Beta channel and all working well. So, you can also try this solution, till Google fix the issue.

We have personally confirmed this method with group of Facebook users facing the issue and for them one out of two methods work flawlessly.

Are you facing Facebook Live showing “Camera Access Denied” Error? Does any of them method fix the issue for you? Let us know in the comments.

Donate on Paypal or Buy us a coffee or Join Patreon if you find the information shared in this blog post useful. Mention ‘Coffee’ in the Subject. So that I can thank you.

Himachali, Mechanical Engineer, Snooker Lover, Avid drinker of Scotch, Traveler, and Webmaster.

Bug Report

Problem

I’m unable to launch the camera on Android.

What is expected to happen?

The camera should launch.

What does actually happen?

The error callback is called with a value of 20, which I believe is PERMISSION_DENIED_ERROR: https://github.com/apache/cordova-plugin-camera/blob/master/src/android/CameraLauncher.java#L98

Information

It’s the only call I make on the page (after device is ready, of course).

Command or Code

window.navigator.camera.getPicture(
  (data: any) =>  alert(`success: ${data}`),
  (err: any) => alert(`error: ${err}`),
);

Environment, Platform, Device

I’ve tried on an LG K20 PLUS running Android 7.0 and a Galaxy S9 running Android 9.

Version information

$ cordova --version
9.0.0 (cordova-lib@9.0.1)
$ cordova platforms
Installed platforms:
  android 8.0.0
  ios 5.0.0
$ cordova plugins list
cordova-custom-config 5.1.0 "cordova-custom-config"
cordova-plugin-add-swift-support 2.0.1 "AddSwiftSupport"
cordova-plugin-advanced-http 2.0.6 "Advanced HTTP plugin"
cordova-plugin-android-referrer 1.0.0 "cordova-plugin-android-referrer"
cordova-plugin-androidx 1.0.2 "cordova-plugin-androidx"
cordova-plugin-androidx-adapter 1.0.2 "cordova-plugin-androidx-adapter"
cordova-plugin-appsflyer-sdk 4.4.15 "AppsFlyer"
cordova-plugin-backbutton 0.3.0 "Backbutton"
cordova-plugin-camera 4.0.3 "Camera"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-dialogs 2.0.1 "Notification"
cordova-plugin-facebook4 4.2.1 "Facebook Connect"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-firebase 2.0.5 "Google Firebase Plugin"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-globalization 1.11.0 "Globalization"
cordova-plugin-inappbrowser 3.1.0-dev "InAppBrowser"
cordova-plugin-ionic-webview 4.0.1 "cordova-plugin-ionic-webview"
cordova-plugin-keyboard 1.2.0 "Keyboard"
cordova-plugin-localtunnel 2.0.3-dev "LocalTunnel"
cordova-plugin-network-information 2.0.2-dev "Network Information"
cordova-plugin-request-location-accuracy 2.2.3 "Request Location Accuracy"
cordova-plugin-request-review 1.0.0 "Request Review"
cordova-plugin-shared-preferences 0.0.1 "Cordova Plugin for Android SharedPreferences"
cordova-plugin-sqlite-2 1.0.6 "SQLitePlugin"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-x-socialsharing 5.4.4 "SocialSharing"
cordova.plugins.diagnostic 4.0.12 "Diagnostic"
es6-promise-plugin 4.2.2 "Promise"
ionic-plugin-deeplinks 1.0.20 "Ionic Deeplink Plugin"
phonegap-plugin-mobile-accessibility 1.0.5-dev "Mobile Accessibility"

Mac OS X 10.14.5

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Понравилась статья? Поделить с друзьями:
  • Неизвестная ошибка импорта сертификата континент ап
  • Неизвестная ошибка закройте программу перезапустите компьютер nanocad
  • Неизвестная ошибка гугл плей
  • Неизвестная ошибка вк при создании беседы
  • Неизвестная ошибка вк при отправке голосового сообщения