Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Requesting Camera permission with Android SDK 23

I'm trying to ask the user to accept a camera permission request. I placed this in my onCreate() method. It's saying it cannot resolve the symbol 'CAMERA'. What's wrong?

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
                ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 1);
            }
        }
like image 857
Martin Erlic Avatar asked Feb 17 '16 08:02

Martin Erlic


1 Answers

You need to import the correct Manifest. You probably have something like this:

import <your_package_name>.Manifest;

Remove it and change with:

import android.Manifest;
like image 171
Mattia Maestrini Avatar answered Oct 23 '22 11:10

Mattia Maestrini