Example code of using sharesdk integrated sharing function in Android

introduction

Now the integration and sharing function of app development is a very common requirement. I haven't used other integration and sharing technologies. Today I'll introduce some basic steps and precautions for sharing function development using sharesdk to help friends avoid some pitfalls. Well, let's get to the point and officially start the introduction.

1. Sharesdk development kit and configuration

Needless to say, go to their official website to find SDK development packages and integration documents.

Android version address: http://www.mob.com/downloadDetail/ShareSDK/android 。

Note: remember to register the sharesdk account to get the appkey. There should be all these integration documents. Just look carefully.

2. Register with major application platforms to obtain appkey and appsecret

This step depends on which platforms your team wants to share, generally microblog and wechat. So generally go to Sina Weibo and wechat development platform to register.

Sina development platform: http://open.weibo.com/

Tencent open platform: https://open.weixin.qq.com/

3. Integration of one click sharing function

Share with sharesdk. If you don't need custom development, you can use the one click sharing module provided in sharesdk. Before using, don't forget to put the jar package and sharesdk.xml in the sharesdk in the specified location (both in the configuration document, just take your time).

Register the following activities under the application node, as shown in the figure:

Note: change the number in the red box to the appid applied on Tencent open platform.

If wechat is integrated into the project, the following wxentryactivity needs to be added. Otherwise, the mob background cannot share wechat statistics: (create a wxapi directory under the project package and then place wxentryactivity)

The code of wxentryactivity.java is as follows:

Now you can call the one click sharing function for simple sharing. Remember to call the sharesdk.initsdk (this) method before calling.

Note: although one click sharing is simple, it is troublesome to modify the one click sharing interface. I heard that it seems much more convenient to modify the interface of the current version? (I don't know, brother. You can go to the integration document to have a look). Let me introduce the user-defined sharing interface.

4. Development of user-defined sharing interface

Look at the renderings first:

Let's introduce the development of this sharing interface in detail

I believe everyone should be familiar with the layout of interface style. I won't post the code of style layout here. In my development, I integrated the sharing function into a component (sharedialog). The detailed code is as follows:

When we customize sharing, we only need to rewrite shareplatform.java. In this file, different sharing logic is executed through different branches. The code is as follows:

We only need to call in this way in the navigation bar to realize the sharing function:

The above example code of using sharesdk integrated sharing function in Android is all the content shared by Xiaobian. I hope it can give you a reference and support more 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
分享
二维码
< <上一篇
下一篇>>