[Easy moment] practical project development (3) Sharing text content to WeChat, easy moment Project Development

Source: Internet
Author: User

[Easy moment] practical project development (3) Sharing text and content, easy moment Project Development

First, you must create an application on the open platform and wait for approval.

 

Note the package name. Do not enter an error in the signature. The created application may not be online yet,

The Application name cannot contain two characters. Otherwise, the application name will be rejected. Generally, the application name can be used within one to two days.

 

Be sure to follow the development guide or the SDK Sample Demo steps strictly.

Use android tools to export a signed apk. Do not use run.

 

If code obfuscation is enabled in the configuration information, to ensure normal use of the sdk,

Add the following two lines in proguard. cfg:

-Keep class com. tencent. mm. sdk .**{

*;

}

If you do not add a shared interface, you may not be able to share it with friends or friends.

 

 

// Register with private void registerToWx () {// obtain the IWXAPI instance api = wxapifacloud through the wxapifacloud factory. createWXAPI (getActivity (), APP_ID, true); // register the appId of the application to the api. registerApp (APP_ID );}

 

/*** It should be noted that the scene member of SendMessageToWX. Req. If scene is filled with WXSceneSession, * the message will be sent to the session. If the scene field is WXSceneTimeline * (4.2 or later, if you need to check whether the version supports API, * You can call the getWXAppSupportAPI method of IWXAPI, and 0x21020001 or above to send a circle of friends ), * The message will be sent to the circle of friends. The default value of scene is WXSceneSession. ** // Share text information to private void sendTextMsgToWx (String text, int select) {// initialize a WXTextObject object WXTextObject textobj = new WXTextObject (); textobj. text = text; // use the WXTextObject object to initialize a WXMediaMessage object WXMediaMessage mediaMsg = new WXMediaMessage (); mediaMsg. mediaObject = textobj; // when a text message is sent, the title field does not work // msg. title = "Will be ignored"; mediaMsg. description = text; // construct a request for SendMessageToWX. req req = New SendMessageToWX. Req (); req. scene = pai_to_wx_friend_zero_type = select? SendMessageToWX. req. WXSceneTimeline: SendMessageToWX. req. WXSceneSession; req. transaction = UtilsHelper. buildTransaction ("text"); // The transaction field uniquely identifies a request req. message = mediaMsg; // call the api to send data to boolean B = api. sendReq (req); UtilsHelper. toast (getActivity (), String. valueOf (B), Gravity. BOTTOM );}}

 

As follows: (it is really difficult to create a GIF animation on an android phone !!)

 

 

 

Not complete...

Related Article

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.