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