This is a common mistake that people make when coding for marshmallow.

When in AppCompatActivity, you should use ActivityCompat.requestPermissions;
When in, you should use simply requestPermissions (this is an instance method of
If you call ActivityCompat.requestPermissions in a fragment, the onRequestPermissionsResult callback is called on the activity and not the fragment.

requestPermissions(permissions, PERMISSIONS_CODE);

If you are calling this code from a fragment it has it’s own requestPermissions method.

So basic concept is, If you are in an Activity, then call

                            new String[]{Manifest.permission.CAMERA},

and if in a Fragment, just call

requestPermissions(new String[]{Manifest.permission.CAMERA},

Check this post to know how to implement Camera Permissions in MarshMallow.


Leave a Reply

Your email address will not be published. Required fields are marked *




Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.