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