Android realizes the function of long press picture saving to album

Foreword: I wrote a study note of reactnative, saying that reactnative has many benefits in the Android framework. Indeed, I also talked about the function of saving pictures to photo albums in our app. Well, I'm still going to write a blog and take it as a note

Let's start with a few app pictures:

As soon as you enter the app, a progress bar loads pictures (I will also talk about the progress bar view and how to monitor the picture loading process later):

After loading the picture:

Long press the picture to enter the album, and you can see the pictures we saved:

Loadingview source code for monitoring image loading (it's not very difficult, I'll post the code directly):

The implementation is still very simple, that is, dynamically change the starting point and end point of the arc at both ends. Through the attribute animation, the code should be relatively clear

An asynctask is used for image loading:

After loading, the picture is stored in the memory card (of course, this is a picture I wrote casually. We can change it to our own loading framework, ha,):

Here, we need to save the pictures to the memory card, so considering the runtime permissions of Android 6.0, the partners must also judge. I judged it when oncreate:

Here's how to save the picture to the album:

Camerarollmanager is the code of the Android module in the reactnatvie of my direct copy:

CameraRollManager.java

GuardedAsyncTask.java:

All right!!! Looking at the simplicity, it took me a whole morning, but I was still unskilled. Well, I felt it was high for a period of time RN, and as a result, Android was native and rusty. If my friends are like me, they must practice often. Both things need to be knocked frequently, otherwise they forget again!!!

Finally, attach the GIT link of the demo: https://github.com/913453448/CamerRoll

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

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
分享
二维码
< <上一篇
下一篇>>