user2966445 user2966445 - 2 months ago 7x
Java Question

Android Studio 2 - Camera SecurityException

I'm trying to use camera intent to capture a photo and display in an ImageView.

Any time the camera intent is started, the following exception occurs:

java.lang.SecurityException: Permission Denial: starting Intent { } from ProcessRecord{c4afeea 3037:com.example.jt.testapp/u0a57} (pid=3037, uid=10057) with revoked permission android.permission.CAMERA

Calling code:

protected void onCreate(Bundle savedInstanceState) {

Button gallery = (Button) findViewById(;
gallery.setOnClickListener(new Gallery(this));

Button camera = (Button) findViewById(;
camera.setOnClickListener(new Camera(this));


What is the correct manifest permission to avoid receiving the above exception?


You are using the right permission: android.permission.CAMERA

When you want access to the Camera permission you have to ask it at runtime when running on Marshmallow.

First check whether the permission is granted and when that isn't the case then request the permission:

if (ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.CAMERA)
    != PackageManager.PERMISSION_GRANTED) {
            new String[]{Manifest.permission.CAMERA},

This is explained here in detail in the documentation: