title: Do apps require permission to open camera and gallery
body: <p>I used to think that to access the camera and gallery from your application, permission is required and specifically in Marshmallow or above permission are required at runtime </p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.CAMERA"/&gt;
      &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/&gt;
  </code></pre>
  
  <p>But I think I was wrong because my app is working without permission also. I have Myapp -> permission. No permission is granted. <strong>But how can it work</strong>. Below is my simple code for gallery  :</p>
  
  <pre><code> @Override
      protected void onCreate ( Bundle savedInstanceState ) {
          super.onCreate ( savedInstanceState );
          setContentView ( R.layout.activity_main );
          takePhoto ( );
      }
  
      public void takePhoto ( ) {
          Intent intent = new Intent ( );
          intent.setType ( "image/*" );
          intent.setAction ( Intent.ACTION_GET_CONTENT );//
          startActivityForResult ( Intent.createChooser ( intent, "Select Image" ), SELECT_IMAGE );
      }
  
      public void onActivityResult ( int requestCode, int resultCode, Intent data ) {
          super.onActivityResult ( requestCode, resultCode, data );
          if ( requestCode == SELECT_IMAGE ) {
              if ( resultCode == Activity.RESULT_OK ) {
                  if ( data != null ) {
                      try {
                          Log.e ( "INSIDE------", "onActivityResult: " );
                          Bitmap bitmap = MediaStore.Images.Media.getBitmap ( this.getContentResolver ( ), data.getData ( ) );
  
                      } catch ( IOException e ) {
                          e.printStackTrace ( );
                      }
  
                  }
              } else if ( resultCode == Activity.RESULT_CANCELED ) {
                  Toast.makeText ( this, "Cancelled", Toast.LENGTH_SHORT ).show ( );
              }
          }
      } 
  </code></pre>
  
  <p>and for camera this is the code :</p>
  
  <pre><code> @Override
      protected void onCreate ( Bundle savedInstanceState ) {
          super.onCreate ( savedInstanceState );
          setContentView ( R.layout.activity_main );
          takePhoto (  );
      }
      public void takePhoto() {
          Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
          startActivityForResult(takePictureIntent, TAKE_PICTURE);
      }
  </code></pre>
  
  <p><strong>My manifest</strong> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
            package="com.example.utkarshshukla.fragmentpractice"&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN"/&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER"/&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>my gradle</strong></p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 26
      buildToolsVersion "26.0.0"
      defaultConfig {
          applicationId "com.example.utkarshshukla.fragmentpractice"
          minSdkVersion 15
          targetSdkVersion 26
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
          exclude group: 'com.android.support', module: 'support-annotations'
      })
      compile 'com.android.support:appcompat-v7:26.+'
      compile 'com.android.support.constraint:constraint-layout:1.0.2'
      compile 'com.android.support:support-v4:26.+'
      testCompile 'junit:junit:4.12'
  }
  </code></pre>
  
  <p>Both of the code works , I haven't declared any permission in manifest. Though after declaring permission in manifest for camera it got crashed saying permission required but without writing in manifest it works  why it works (not tried same for gallery).In developers site they have mentioned to take permission but didn't mention what will happen if no permission taken.<br>
  <strong><em>Question is why it is working without permissions</em></strong></p>
  
  <p>Thanks  </p>