This article describes the detailed analysis of the WeChat SDK sharing function process steps in Android programming. Share it for your reference, as follows:
I have analyzed how to use the official demo to share WeChat information before. I won’t say more about it here. It is very simple to share my own application. The author of this article has made it successful after some trouble. In order to avoid detours in the future, I decided to introduce how to share functions in my application from beginning to end.
Note: The order cannot be messed up! !
1. Build your own application TestShareWX
(1) The application package name is, and then create a test activity, the name is TestActivity, which contains a Button and EditText.
(2) Run the program, please remember that when you compile and run it, you use the default signature of Android.
2. Download the development toolkit in the official website/download/?lang=zh_CN, unzip, copy it to libs, and add it to the build path.
3. Register your application at the official website/agreement.
The previous basic operations are omitted here, and the following steps should be paid attention to here.
One step is to sign our program with an apk tool that signs the WeChat name. Because our program has been installed, we can download and install it directly, and then enter the package name in the box inside the phone (I am here, the package name cannot be filled in incorrectly), click the Generate button, and an md5 value will be generated and entered into the box on the registration page (at this time, let's note that if our application has not been installed in the phone, the signature tool will prompt that there is no relevant package description. Have we realized something at this time?)
Next, enter the package name (I am here, the package name cannot be filled in incorrectly), and submit it for review. Next, wait for WeChat’s MM to review.
4. In step 3, we have obtained the appid. According to the method provided in SDK Demo, we will test it in our TestActivity. OK. Everything is successful. Do you feel a sense of accomplishment?
5. The life of the coder is really sad. I work overtime and code. The days pass by day and the project is developing to the end. After testing, everything is normal and I use a formally signed file pair to formally package it. Then test again. OH, my god, What Happened! ! ! Why can I share WeChat just now? Now I clicked but it didn’t respond. Suddenly he fell into panic. . . . Don't be afraid, I'll tell you why this happens.
6. In fact, in the first step, we have already said that when we fill in the application signature on the AppId we applied for on the official website, it is also generated. However, the apk we run in our mobile phone at this time is signed with our own generated signature () and the two signatures are inconsistent, so it is natural that it will lead to sharing failure. Because WeChat needs to verify our application, it is to authenticate it through this signature.
7. Don’t worry, there is a remedy method. Use our official signature file to formally package the program, then install it into your mobile phone, and then run the WeChat signature apk tool again, enter our package name into it, regenerate an MD5 signature, and then go to the official website/agreement to find the application of your previous level, pull it to the end, click Modify, enter the signature you just generated into it, and save it and submit it to review.
8. After doing the above, all you have to do is wait for the resubmitted modification to pass the review, otherwise your WeChat will not be able to share successfully.
9. One day, the registered application passed the review, run the packaged program, click WeChat, oh, yes. I found that I could share it and finally I could take a breath.
Remark:
During the sharing process, the author of this article also encountered many problems. Let me tell you here to pay attention to it later.
1. It’s still a signature problem. If a project is completed by several people, if everyone uses their own defaults to run it, in the debug version, the WeChat sharing function will definitely be normal only if the Apk produced by the WeChat appid machine applied for.
2. Regarding the feedback on the results of sharing information on WeChat, we should pay attention to the following two points. Whether you want to share feedback will definitely not be received.
(1) The name of this Activity must be WXEntryActivity
(2) The WXEntryActivity class must be built under the application package name + wxapi package (for example, the above project, the package name should be)
After writing this, it’s finally over. The author of this article has been working hard for a long time before he understands the principle of WeChat authentication. In a word, it is important to understand signatures.
I hope this article will be helpful to everyone's Android programming design.