title: How to ask runtime permissions for Camera in Android , Runtime storage permissions
body: <p>I am doing an application to scan barcodes on a button click and it was working fine up to Lollipop versions. When I came to Marshmallow it stopped working. This is the error:</p>
  
  <blockquote>
    <p>camerabase an error occurred while connecting to camera 0</p>
  </blockquote>
  
  <p>It forces me to turn on permission by:</p>
  
  <p>Settings --> application --> my app --> camera.</p>
  
  <p>My question is how to allow camera permission to my app automatically in Marshmallow or by asking the user to turn on camera at runtime. A screen shot:</p>
  
  <p><a href="https://i.stack.imgur.com/FTSZA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FTSZA.png" alt="enter image description here"></a></p>