


I have discovered some pitfalls after logging in and sharing on Android WeChat for a while.
Some pitfalls I have discovered after doing WeChat login and sharing for a while:
1. First of all, in addition to obtaining the AppID, the Android application must pass the review. Otherwise, WeChat cannot be called up for sharing, and it needs to be on the website. Fill in the package name and signature fields. The signature can be obtained using the signature generation tool. If you have special needs, please refer to "Signature Generation Method" to generate it yourself.
See WeChat Open Platform-->Mobile Application-->FAQ-->Android FAQ and WeChat Open Platform-->Resource Download-->android Resource Download-->Signature Generation Tool Download
2. The signature and package name in the first step must be written correctly. The second question is how to receive the callback from WeChat
a. Create a new wxapi directory in the directory corresponding to your package name. , and add a WXEntryActivity class in the wxapi directory, which inherits from Activity()
And add the exported attribute to the manifest file, set it to true, and set the startup mode to singleTop to ensure that it will not be created repeatedly.
Because WeChat will call up a new activity: WXEntryActivity when calling back, so the transparent style must be set (otherwise the user will perceive that a new activity is started), and finish WXEntryActivity in the onResp method
For example:
<!--非要设置成透明的才不会对用户造成困扰--> <activity android:name=".wxapi.WXEntryActivity" android:theme="@android:style/Theme.Translucent" android:label="@string/app_name" android:exported="true" android:launchMode="singleTop"> <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <data android:scheme="sdksample"/> </intent-filter> </activity>
b. Implement the IWXAPIEventHandler interface, the request sent by WeChat will be called back to the onReq method, and the response result sent to the WeChat request will be called back to the onResp method
c. In WXEntryActivity, the received The intent and the object that implements the IWXAPIEventHandler interface are passed to the handleIntent method of the IWXAPI interface, and the onResp method will be corresponding.
Related articles:
Detailed explanation of the method of Android programming to implement WeChat sharing information
Related videos:
The above is the detailed content of I have discovered some pitfalls after logging in and sharing on Android WeChat for a while.. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)