Third-party Android apps share images and text to WeChat moments & amp; WeChat callback notification sharing status

Source: Internet
Author: User


<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + signature + cve-vcd4kpha + signature/Signature vcD4KPHA + PGJyPgo8L3A + signature/Signature + signature + cve-vcd4kpha + tdrI/Signature + Signature 9Pr1Nq/release + PC9wPgo8cHJlIGNsYXNzPQ = "brush: java; "> IWXAPI api = wxapifacloud. createWXAPI (context, APP_ID, false); api. registerApp (APP_ID); WXWebpageObject webpage = new WXWebpageObject (); webpage. webpageUrl = "http://www.xxxx.com/wap/showShare/;WXMediaMessage msg = new WXMediaMessage (webpage); msg. title = "My offer"; msg. description = "I want to share"; try {Bitmap bmp = BitmapFactory. decodeResource (getResources (), R. drawable. send_img); Bitmap thumbBmp = Bitmap. createScaledBitmap (bmp, 150,150, true); bmp. recycle (); msg. setThumbImage (thumbBmp);} catch (Exception e) {e. printStackTrace ();} SendMessageToWX. req req = new SendMessageToWX. req (); req. transaction = String. valueOf (System. currentTimeMillis (); req. message = msg; req. scene = SendMessageToWX. req. WXSceneTimeline; api. sendReq (req );

If everything goes well, you will see a similar image at the beginning of the article.

Click Cancel or share.


Step 4: add the prompt callback page.

(1) create a new package

The rule is your package name plus wxapi [for example, com. xxx. wxapi]


(2) Add a class in the newly created package, WXEntryActivity. java. The name must be consistent, which is specified by the open platform.

package com.xxx.wxapi;import android.app.Activity;import android.os.Bundle;import android.widget.Toast;import com.lbt.hairdesigner.R;import com.lbt.hairdesigner.utils.MySetting;import com.tencent.mm.sdk.openapi.BaseReq;import com.tencent.mm.sdk.openapi.BaseResp;import com.tencent.mm.sdk.openapi.IWXAPI;import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;import com.tencent.mm.sdk.openapi.WXAPIFactory;public class WXEntryActivity extends Activity implements IWXAPIEventHandler{private IWXAPI api;@Overrideprotected void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);api = WXAPIFactory.createWXAPI(this, APP_ID, false);api.registerApp(APP_ID);api.handleIntent(getIntent(), this);}@Overridepublic void onReq(BaseReq req){}@Overridepublic void onResp(BaseResp resp){int result = 0;switch (resp.errCode){case BaseResp.ErrCode.ERR_OK:result = R.string.errcode_success;break;case BaseResp.ErrCode.ERR_USER_CANCEL:result = R.string.errcode_cancel;break;case BaseResp.ErrCode.ERR_AUTH_DENIED:result = R.string.errcode_deny;break;default:result = R.string.errcode_unknown;break;}Toast.makeText(this, result, Toast.LENGTH_LONG).show();finish();overridePendingTransition(R.anim.change_in, R.anim.change_out);}}

(3) add some characters to string. xml
 
  
Sent successfully
 
 
  
Cancel sending
 
 
  
The message is rejected.
 
 
  
Send back
 

(4) Attach change_in.xml and change_out.xml

 
     
  
 

 
     
      
 

Finally, no matter where you call the third-step sharing, a callback prompt will be displayed.




============ THE ==== END ====================================


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.