private void requestCameraPermission ( ) { int permissionCheck = ContextCompat . checkSelfPermission ( this , Manifest . permission . CAMERA ) ; if ( permissionCheck != android . content . pm . PackageManager . PERMISSION_GRANTED ) { ActivityCompat . requestPermissions ( this , new String [ ] { Manifest . permission . CAMERA } , 0 ) ; // a dialog should open and this dialog will resume when a decision has been made } }
Newer versions of Android require explicit permission from the user