android6.0+ need to manually add permission descriptions

Source: Internet
Author: User

This time just to get a webview upload a function, need to use the camera and read the file so a piece, just what their own Xiaomi 5 mobile phone is more than 6.0, and now a lot of mobile phones are also 6.0+, so also encountered some later have to encounter trouble, But this is relative to the development of the people with eclipse, as the specific do not know how to get. 6.0 ago Everyone is in the Androidmanifest file directly add the relevant permissions, but seemingly 6.0 after the majority of mobile phones so add no effect, so you need to manually in the code to add permission to remind, the following is a manual add permission to a function, directly on the code:

private void Boolopencarmer () {
if (Contextcompat.checkselfpermission (this, Manifest.permission.CAMERA)//Open Camera permissions
! = packagemanager.permission_granted | |
Contextcompat.checkselfpermission (this, Manifest.permission.READ_EXTERNAL_STORAGE)//readable
! = packagemanager.permission_granted | |
Contextcompat.checkselfpermission (this, Manifest.permission.WRITE_EXTERNAL_STORAGE)//writable
! = packagemanager.permission_granted) {
Request Write_external_storage Permission
Activitycompat.requestpermissions (This, new String[]{manifest.permission.camera,manifest.permission.read_ External_storage
, Manifest.permission.WRITE_EXTERNAL_STORAGE},
1);}
}

Put this method directly into the OnCreate () or Onresume () method, load on initialization, or load when you need to use this permission.

android6.0+ need to manually add permission descriptions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.