Android M - failed to check runtime permission
<p>I have just started working with runtime permissions on Android M. I have CAMERA, READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE declared in AndroidManifest.xml</p>

<p>The thing is if user go to Settings and explicitly turn off permissions as below, I cannot check if my app that has Camera or Storage permissions enabled or not</p>

<p><a href="https://i.stack.imgur.com/1RewP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1RewP.jpg" alt="enter image description here"></a></p>

<p>I used this snippet to check if my app has a particular permission or not:</p>

<pre><code>public static boolean hasPermission(Context c, String permission) {
    if (Build.VERSION.SDK_INT &gt;= 23) {
        return ContextCompat.checkSelfPermission(c, permission) == PackageManager.PERMISSION_GRANTED;
    }
    return true;
}
</code></pre>

<p>Surprisingly, every check with Camera and Storage permissions returns true (granted) even I turned them off in my Settings.</p>

<p>My <code>targetSdkVersion</code> is 23</p>

<p>Is this expected behavior provided by Google? I looked around the web and still could not find any documentation say anything about handle explicitly-invoked permissions.</p>