Recently just after the year, a return to the company and the project to add sharing functions, make a mess, and now here to record the process occurred in the problem, convenient next check.
First, the sharing feature is implemented in two ways:
1: Register the developer on each platform, download the SDK, read the documentation, view the official demo, integrate the SDK, write code tests, fix bugs, optimize.
Well, see such a long list of steps, and is each want to integrate the platform to run through the process, the heart of Death has, program 1 directly give up.
2: Use the SDK for each platform that the third party has integrated.
This solution is also used by most applications today, for a simple reason: free! Convenient! Fast!
And the third-party SDK also have a few can choose, with more is the mob of SHARESDK, Friends of the alliance, as if Baidu also has.
I finally used the mob, the reason is very simple, most people use.
Start Integration:
The integration of SHARESDK is simple, and we follow the official documentation to go straight through the process:
I. Acquisition of Appkey
Register the Mob's account and fill in some of your application's basic information, get Appkey, this appkey back useful, first remember, note it is best to use the company's mailbox instead of the personal mailbox registration, maybe that day you ran away.
Second, download the SDK
This is nothing to say, choose the platform you want, then click "Download SDK" on the line
Three, rapid integration
3.1 Using Quickintegrate.jar
Mob provides a quick integration tool Quickintegrate.jar to quickly generate the code and resources you need for the platform you choose, and there are two points to note about Quickintegrate.jar:
(1) Unable to open Quickintegrate.jar
The document says that after configuring the Java environment under Windows, you can double-click Open Jar, anyway, my computer is no good. The workaround is simple, just open it with the command line: CD to Quickintegrate.jar directory, run "Java-jar quickintegrate.jar" command. after the quickintegrate runs successfully, a sample folder is generated in the directory where it is located, andthere are 4 subfolders under the sample folder: Assets,libs,res,src.
Copy the contents of these 4 subfolders into your project and it's OK!
(2) No platform can be selected after opening Quickintegrate.jar
This is because in the second step to download the SDK when you choose "Download the official demo", this is although the folder also has Quickintegrate.jar after decompression, but this Quickintegrate.jar can not use, you should point is "Download SDK."
3.2 Configuring Androidmanifest.xml
Add permissions and activity what the direct copy on the line, pay attention to do not repeat (as if repeating it is OK, but check it is also a good habit), there is integration and forex words need to register an additional two activity, the wxentryactivity and the letter Yxentryactivity. Note that the Name property corresponds to the package path, which is used directly on the official document "." Start with the current package name, typically the package name of your project, and these two activities are placed under Cn.sharesdk.demo, either change the Name property to the correct package path, or put the two activity in the corresponding package in your project, Otherwise it will report Activitynotfound exception.
In fact, this step is the most annoying is the last step: replace the mob background application Appkey and the various platform application key
This step you have to each of your integrated platform to register the developer, of course, you can also directly with the mob application of the platform of the Appkey, but this is someone else's thing, no problem, I now except some registered developers failed platform with the appkey outside of the mob, The others are registered on their own. And some platforms for security reasons, will go to verify the signature, these platforms we have to register themselves, and submit application information through the audit before it can be used.
Each platform's registered address can be Baidu, or in assets Sharesdk.xml, or review the Web version summary: Application information Registration address List
You need to register yourself:
(1) Sina Weibo SSO
SSO is similar to a key login, if you are already installed on the current mobile phone Sina Weibo client, then open SSO can be directly a simple one-click authorization to share, instead of the account password input. It's convenient, but for security reasons, Sina has added validation of application signatures. Therefore, we must submit our application and signature information to Sina and pass the audit before the SSO-free function can be done.
Note Fill in the Application information required to fill in the signature of the MD5 value, as with other MD5 values, this is the unique identity of your signature, in the generation of signature files Keystone can be seen, if you did not remember, you can also use Sina or other development of a simple application to get. Sina Tools Git-hub Address: Click to open the link
Note Whether you are using Sina or the other platform to provide tools, your signature MD5 value only one, you use which tool to get the same results, you extract it once and then remember it can be used on each platform.
(2), Circle of Friends
and its circle of friends also to verify the application signature, and it is only after the validation to give you appid. When you share content will be on the server side of your package name and signature of the corresponding verification, if not on the server side of your package name and signature information or not corresponding, will be an error resulting in sharing failure.
Note that in the test sharing, you must first fill in the signed file signed after the package before the test, as said above, will verify your package name and signature, do not let you share.
(3) Easy to believe, easy to trust friends Circle
Basically the same.
Pay attention to auditing, otherwise you may limit the content or not share it at all. I passed the audit, Sina's and the letter has not passed (well, write to half of Sina's also passed the audit, the difference is easy to believe), if the failure will tell you why, more application several times.
3.3 Start adding share code
The simple one-click Sharing code is simple, and the sample code on the document is copied directly to the line. Note If your app hasn't been approved yet, it's a good idea to turn off SSO licensing.
Having done the steps above is basically a simple sharing function, but I think there is a high level of customization that is necessary to achieve the difference between the different platforms to share content:
Different platform sharing content format is different, such as Weibo only support graphics and text sharing, and easy-to-letter support Web sharing. So it's a good idea to set up different shared content for different platforms.
The Mob SDK also provides a simple callback interface to implement this function.
Specific reference: the 6th Official document
Content format reference for each platform: a detailed description of the content shared by different platforms
This is a text version, because the pages of the various platforms are always changed to change, hair pictures do not mean anything.
Android Curiosity Baby _12_ social sharing those things