Third-party app sharing to WeChat moments

Source: Internet
Author: User

For the most authoritative learning materials, visit the official website and the demo provided on the official website. Basically, you can use it directly. This is the official website: http://open.weixin.qq.com /.

In the sharing process, the following problems are encountered: The first time you can share a file, you will not be able to call the sharing dialog box in the future. This is not a program issue, but a review is required. The sharing dialog box can be called up only after the review is passed. Don't believe it? Then, you can quit and click share again. Then, the Login Dialog Box will pop up, and there will be no sharing dialog box after login. It's no problem for you.

In addition, when sharing and developing the Android version, the application signature (the signature generation tool provided on the official website is recommended) is determined by the digital certificate used for packaging. Don't believe it? Uninstall the program first, and then rename your application package name. Do not change the digital certificate and run it. Use this signature generation tool to obtain the application signature, which is exactly the same. Therefore, it is better to generate a digital certificate for the official application release. If the signature is not very understandable, see my previous article: http://blog.csdn.net/qianfu111/article/details/9113887

The following is the program source code for simple text sharing. Of course, you also need to import the jar package:

Package COM. example. share; import android. app. activity; import android. OS. bundle; import android. view. menu; import android. view. view; import android. widget. button; import COM. haifei. share. r; import COM. tencent. mm. SDK. openapi. iwxapi; import COM. tencent. mm. SDK. openapi. sendmessagetowx; import COM. tencent. mm. SDK. openapi. wxapifacloud; import COM. tencent. mm. SDK. openapi. wxmediamessage; import COM. tencent. mm. SDK. openapi. wxtextobject; public class mainactivity extends activity {private final string app_id = "wxbd8d9e9f2e348364"; @ override public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. activity_main); button sharebtn = (button) findviewbyid (R. id. button1); Final iwxapi API = wxapifacloud. createwxapi (getapplicationcontext (), app_id, true); API. registerapp (app_id); sharebtn. setonclicklistener (new view. onclicklistener () {@ overridepublic void onclick (view V) {// todo auto-generated method stub // share to your circle of friends // initialize a wxtextobject object string text = "share our application"; wxtextobject textobj = new wxtextobject (); textobj. TEXT = text; wxmediamessage MSG = new wxmediamessage (textobj); MSG. mediaobject = textobj; MSG. description = text; sendmessagetowx. REQ Req = new sendmessagetowx. req (); req. transaction = string. valueof (system. currenttimemillis (); req. message = MSG; API. sendreq (req) ;}}) ;}@ override public Boolean oncreateoptionsmenu (menu) {getmenuinflater (). inflate (R. menu. activity_main, menu); Return true ;}}

Here: http://blog.csdn.net/dengbodb/article/details/7840113

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.