Example code of Android application accessing wechat sharing
In recent projects, wechat sharing will be accessed, and the access process will be recorded
Register application information and download necessary tools
Note: due to the inconsistency between the general debugging signature and the official signature, the signature of the test package can be filled in during testing, and it needs to be changed to the signature of the official package when going online
Access
In build.gradle, add the following dependencies:
Or:
The former includes statistical functions
Add permissions and wechat callback activity in androidmanifest.xml
A transparent activity is used here to handle the callback of wechat sharing results
Subject:
Activity
When wechat sharing is successful and click return app, wechat will actively call wxentryactivity and pass the result to wxentryactivity through intent. At this time, api.handleintent (getintent(), this) is called to process the result. The second parameter of handleintent is iwxapieventhandler. The shared result will be processed in onresp method. Here we send a broadcast, And listen to the broadcast in the wxshare object
Tool class
Interface
use
In activities that require wechat sharing:
Start sharing
Here, wechat sharing is complete!
In addition, in the wechat official routine, there is a receiver that regularly refreshes the application registration information
Add to androidmanifest.xml:
code:
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.