Android third party login and sharing (sharesdk and Youmeng)

Prepare for the following project and write a demo for third-party login and sharing. Sharesdk and Youmeng are used respectively.

First, let's talk about my feelings about the use of the two. Personally, I think sharesdk is better than Youmeng. What's the good about it? The good thing is the human service. Various problems have been encountered in the process of integration, but sharesdk's manual service is very good, which can answer questions and provide solutions to problems! Next, add the code (this article is developed using Android studio, sharesdk version v2.7.7, Youmeng version v6.0.0):

1、 Use sharesdk (sharesdk version v2.7.7) to integrate:

1. To go to the official website: http://www.mob.com/ Register an account, add an application, download the SDK, register an application on Sina, wechat and QQ open platforms respectively, and get the key. Get these ready and let's start! 2. Add the following permissions to the manifest file:

3. Continue to add activity information, * * note here that the appid after Tencent should be consistent with the appid of QQ you configured * *:

4. Go to sharesdk.net under the assets directory Modify the prepared keys of QQ, wechat and microblog in the XML directory. Note here: 4.1. The assets folder is in the root directory of main. 4.2. QQ and qzone use the same appid and appkey 4.3. Wechat and circle of friends and collections use the same appid and appsecret 4.4. Besides configuring appkey and appsecret, the redirecturl needs to be configured for microblog=“ http://sns.whalecloud.com/sina2/callback "The value of redirecturl is consistent with the authorization callback page at the microblog application information

5. Add wechat callback 5.1. Create a package named "wxapi" below the package name 5.2. Put "wxentryactivity" in the demo. Note that this class does not need to be moved and called manually! [location of wxentryactivity]( http://img.blog.csdn.net/20161015153103561 )

6. Go write code and prepare publicstaticdata in advance java:

6.0 initializing publicstaticdata myShareSDK= new ShareSDK(); PublicStaticData. myShareSDK. initSDK(getApplicationContext()); 6.1. Open the sharing panel

6.2. Share to the designated platform (wechat and microblog are used here as examples)

6.3 third party login

6.4 login and share callback (a listener used for sharing and login here)

7. So far, there are three common login and sharing methods for using sharesdk integration. There are no serious problems in the whole process, and the overall experience effect is good. Overall code sharesdkutils java:

Use in activity

2、 Use Youmeng to integrate (Youmeng version v6.0.0 (compact version)):

1. The process of registering, downloading SDK and preparing key is omitted here. Start with integration directly. 2. Permissions:

3. Add activity information (the simplified version of Weibo is used here, and Sina Weibo does not need to call back activity) * * note that the appid behind Tencent should be consistent with the appid of QQ you configured * *:

4. Upper Code:

4.0 initialization:

4.1 open the sharing panel

4.2 share to the top platform

4.3 share listening callback

4.4 login

4.5 login callback

5. On some low-end mobile phones, there may be no callback on QQ. You need to add the following code to the activity:

6. Similarly, there is no callback. This is wechat. You need to add code to wxentryactivity:

7. So far, three common login and sharing methods are completed by using Youmeng integration. Upper overall code umengshare java:

Use in activity:

Finally, the two methods are integrated. Let's use them quickly. My ability is effective. If the bug is purely normal! Sharesdk is recommended!

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