Method to solve the problem that Android can’t cut out pictures due to errors in getting pictures from photo albums

I encountered a big problem when learning to obtain the pictures in the album for cutting. It took nearly half a day to really solve it. Let's share our learning experience. Problem: after selecting the pictures in the album, there was an error when you want to enter the picture cutting. The (Huawei) mobile phone prompted "this picture cannot be obtained". After Baidu, it was understood that the problem of URI was caused by different versions. The original text is as follows:

After the program can be run, certain tests are also carried out, as shown in the following figure:

First, use the return value received by onactivityresult as toast output:

The following results are obtained:

Then, the absolute path of the picture is used as toast output:

The following results are obtained:

Sure enough, as the blog said, how to modify it? Due to the different problems encountered by various readers, we can only attach the pictures selected by the author from the album and the cut source code for reference only.

If you don't understand, you can visit the author's last blog and run the demo provided by the author.

MainActivity:

The above is the way to solve the problem that Android pictures cannot be cut. I hope it will be helpful to your study.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>