[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...