title: Open camera with clicking a button, app crashes
body: <p>I am using API 26. I want to open the camera after a user clicks a button. I have the button and it's id is CAMERA. I call <code>openCamera</code> method when a button is tapped. </p>
  
  <pre><code>public void openCamera(View v){
  
      if(v.getId() == R.id.CAMERA) {
  
          Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
          startActivityForResult(intent,0);
      }
  }
  </code></pre>
  
  <p>This method is in the MainActivity class, but the button itself is in its own class called "Create"</p>
  
  <pre><code>// Create class
  public class Create extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.create);
  
      }
  }
  </code></pre>
  
  <p>I am not seeing what I am doing wrong since the method should work and is linked to the button.</p>
  
  <p><strong>Exception Stack Trace</strong>:</p>
  
  <pre><code>5906-5906/com.gif.gif E/AndroidRuntime: FATAL EXCEPTION: main Process: com.gif.gif, PID: 5906
  
  java.lang.IllegalStateException: Could not execute method for android:onClick
     at android.view.View$DeclaredOnClickListener.onClick(View.java:5336)
     at android.view.View.performClick(View.java:6256)
     .
     .
     .
     . 
      Caused by: java.lang.SecurityException: Permission Denial: starting Intent { 
          act=android.media.action.IMAGE_CAPTURE cmp=com.android.camera2/com.android.camera.CaptureActivity 
      } from ProcessRecord{5ce0ad0 5906:com.gif.gif/u0a84} (pid=5906, uid=10084) 
      with revoked permission android.permission.CAMERA
      at android.os.Parcel.readException(Parcel.java:1942)
      at android.os.Parcel.readException(Parcel.java:1888)
      at android.app.IActivityManager$Stub$Proxy.startActivity(IActivityManager.java:4365)
      at android.app.Instrumentation.execStartActivity(Instrumentation.java:1610)
      at android.app.Activity.startActivityForResult(Activity.java:4472)
  </code></pre>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>package com.gif.gif;
  import android.view.View;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.util.Log;
  import android.content.Intent;
  
  public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Log.v("gif", "onCreate triggered");
      }
  
      public void onButtonClick(View v) {
  
          if(v.getId() == R.id.CREATE) {
  
              Intent i = new Intent(MainActivity.this,create.class);
              startActivity(i);
          }
  
      }
  
      public void openCamera(View v) {
  
          if(v.getId() == R.id.CAMERA) {
              Intent intent = new 
              Intent("android.media.action.IMAGE_CAPTURE");
              startActivityForResult(intent,0);
          }
  
      }
  
      protected void onStart() {
          super.onStart();
          Log.v("gif", "onStart triggered");
      }
  
      protected void onResume(){
          super.onResume();
          Log.v("gif", "onResume triggered");
      }
  
      protected void onPause(){
          super.onPause();
          Log.v("gif", "onPause triggered");
      }
  
      protected void onStop(){
          super.onStop();
          Log.v("gif", "onStop triggered");
      }
  
      protected void onDestroy(){
          super.onDestroy();
          Log.v("gif", "onDestory triggered");
      }
  
  }
  </code></pre>
  
  <p>My XML code is at <a href="https://pastebin.com/M5BC8K9V" rel="nofollow noreferrer">https://pastebin.com/M5BC8K9V</a> </p>