Home > Mobile >  How to realize the share a link in the APP, by clicking on the link call WeChat WeChat applet open??
How to realize the share a link in the APP, by clicking on the link call WeChat WeChat applet open??

Time:04-26

Company product you would like to add a feature in the APP or share a link or qr code in the mobile browser, users can click the link or recognition of qr code calls open WeChat WeChat small programs, have a great spirit to realize the similar functionality??????? Strives for the interpretation of the

CodePudding user response:

Android APP tuning a small program





A, demand



1, in the morning just to do new demand from our client to jump to its designated small program, our products is APP pull up a small program that specify

Note: the above leadership in April is actually put forward the demand, then through the blogger WeChat open platform, did not find, can only mail the official, the official to reply: temporary not opened the class interface application channels, attention please open platform website announcement information, thank you support!





Second, knowledge scope


The default readers have WeChat open platform registered account, mobile application development, small program (there can skip the second point, directly into the theme)


Readers who never access WeChat SDK (small programs, etc.), can quickly scan WeChat open document

Blogger simple overview WeChat open platform steps are as follows:


Registered WeChat open platform account: WeChat open platform
Login again after management center - mobile applications - to create mobile applications (detailed steps for the reader to see the document should be faster than the blogger understand)
Pay attention to the AppId application, signature with the package name can (download WeChat get signature tool, a blogger here on pit, lifted me up and then write)




Three, the code (full)

CallProgramAcitivity page bo Lord spun off from the project, wrote a page separately, fully meet the requirements and function point

The code is as follows:



Public class CallProgramAcitivity extends AppCompatActivity {

Private Button mBt.

@ Override
Protected void onCreate (@ Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
The setContentView (R.l ayout. Activity_callprogram);

MBt=the findViewById (R.i db t);
MBt. SetOnClickListener (new View. An OnClickListener () {
@ Override
Public void onClick (View v) {
String appId=AppConfig. WEIXIN_APP_ID;//fill in the application AppId
IWXAPI API=WXAPIFactory. CreateWXAPI (CallProgramAcitivity. This, appId);

WXLaunchMiniProgram. The Req the Req=new WXLaunchMiniProgram. The Req ();
The req. UserName=AppConfig. WEIXIN_XIAOCHENGXU_ID;//fill small program original id
The req. Path="/pages/home/home? Kx=KXX ";//pull a small program can take and path of the page, a thin application will not fill the default home page
The req. MiniprogramType=WXLaunchMiniProgram. The req. MINIPTOGRAM_TYPE_RELEASE;//optional open development version, experience and formal version
API. SendReq (the req);
}
});
}
} 12345678910111213141516171819202122232425

Corresponding page layout activity_callprogram. XML



<? The XML version="1.0" encoding="utf-8"?>
Android: orientation="vertical"
Android: layout_width="match_parent"
Android: layout_height="match_parent" & gt;

The android: id="@ + id/bt"
Android: text="APP tuning up the specified small program"
Android: layout_width="match_parent"
Android: layout_height="wrap_content"/& gt;

12345678910111213

Pay attention to add WeChat dependent libraries in APP build. Gradle
The official document:
WeChat official document


//wechat share login to collect payment, etc.
//the compile 'com. Tencent. Mm. Opensdk: wechat - SDK - android - with - the mta: +'
The compile 'com. Tencent. Mm. Opensdk: wechat - SDK - android - without - the mta: +'
123
Pay attention to add files wxapi add WXEntryActivity



@ Override
Public void onResp (BaseResp BaseResp) {
//2018/8/29 App tuning a small program
If (baseResp. GetType ()==MAND_LAUNCH_WX_MINIPROGRAM ConstantsAPI.COM {
WXLaunchMiniProgram. Resp launchMiniProResp=(WXLaunchMiniProgram. Resp) baseResp;
String extraData=https://bbs.csdn.net/topics/launchMiniProResp.extMsg;//corresponding small program component
  • Related