Android screenshot sharing function

Recent projects need to realize the Android screenshot sharing function, including Android screenshots to obtain pictures, save pictures locally, notify the system to update photo albums, and share screenshots through wechat, QQ and microblog. This article is a summary and review.

1、 Android screenshot to get pictures

The bitmap is obtained by drawing the view. You can draw activities, fragments, and other views.

1. Screenshot of activity (with blank status bar)

2. Screenshot of activity (remove the status bar)

3 fragment screenshot

The method of drawing view is only applicable to static view, surfaceview, ijkvideoview and other views playing video, and cannot be intercepted; In addition, some animation class views cannot be intercepted. In view of the above situation, one frame of surfaceview can be obtained to generate bitmap, and the bitmap can be merged. Similarly, animation view can also be merged. For example, the bottom layer plays video, the middle layer plays animation, and the top layer is an ordinary view. Bitmap can be combined as follows:

Note: the drawing of the view must be completed in the UI thread, otherwise it will crash; The merging of bitmap is time-consuming and needs to be completed in the child thread.

2、 Save bitmap locally

3、 Notify system of album updates

4、 Share through wechat, QQ and microblog

It is realized through the SDK shared by wechat, QQ and microblog, as follows:

1 share with wechat circle of friends

2. Share with wechat friends</h3>

4 QQ space sharing

5 microblog sharing

summary

The above is the Android screenshot sharing function introduced by Xiaobian. I hope it will help you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

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