Android bitmapfactory.decodefile (FilePath, Options) returns Null 6.0 permissions

Source: Internet
Author: User
Tags throw exception

Today in the photo upload encountered a problem, according to the path to get bitmap failure, always return empty, think this path to get bitmap code is tried, do not doubt it, to find the correct parameters, the initial suspicion is FilePath did not pass in, print FilePath.

But found that FilePath have value, played a strange, step by step debug, found every step is correct, no problem, but one to the last return Bitmapfactory.decodefile (FilePath, Options); is empty, hesitation this method is Android, so there is no way to step into the debug.

Change the method of converting bitmap, find throw exception, print, permission is denied.

According to the code, know that this step must be Read and Write permissions, first, go to the register to find, but found all in.

Test again, the code to print whether to get permissions,-1, no permissions, it is strange, is not the registration authority useless?

You can see that the return value of 0 indicates that the permission is available, and a return value of 1 indicates that the permission is not

At this point, I think of the adaptation of our project, Target is 24, 6.0 is 23, and 6.0 has a new feature is dynamic permissions, that is, write and read permissions are to be obtained in the code.

Android bitmapfactory.decodefile (FilePath, Options) returns Null 6.0 permissions

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.