How get permission for camera in android.(Specifically Marshmallow)

前端 未结 6 1590
遇见更好的自我
遇见更好的自我 2020-11-30 01:53

Hey I am designing an app in android studio. In which i require permission of camera. I have included

6条回答
  •  臣服心动
    2020-11-30 02:20

    First check if the user has granted the permission:

    if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA)
        == PackageManager.PERMISSION_DENIED)
    

    Then, you could use this to request to the user:

    ActivityCompat.requestPermissions(activity, new String[] {Manifest.permission.CAMERA}, requestCode);
    

    And in Marshmallow, it will appear in a dialog

提交回复
热议问题