sinat_29351891
sinat_29351891
采纳率44.4%
2015-07-24 03:20 浏览 4.9k

Android 微信分享成功后没有回调

2

public class WXPayEntryActivity extends Activity implements
IWXAPIEventHandler,OnClickListener {
private IWXAPI wx_api;
ImageView share_friend;
ImageView share_circle;
TextView cancel;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fenxiang);
    share_friend = (ImageView) findViewById(R.id.share_friend);
    share_circle = (ImageView) findViewById(R.id.share_circle);
    cancel = (TextView) findViewById(R.id.quxiao);
    share_friend.setOnClickListener(this);
    share_circle.setOnClickListener(this);
    cancel.setOnClickListener(this);
    regToWx();
}

public void cancel(View view) {
    finish();
}

private void regToWx() {
    wx_api = WXAPIFactory.createWXAPI(this, "wx39f190a482377e7a");
    wx_api.registerApp("wx39f190a482377e7a");
    //wx_api.handleIntent(getIntent(), this);
}

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);
    wx_api.handleIntent(intent, this);
}

public void weiChatShareFriend() {
    if (!wx_api.isWXAppInstalled()) {  
        Toast.makeText(WXPayEntryActivity.this, "您还未安装微信客户端",  
                Toast.LENGTH_SHORT).show();  
        return;  
    }  
    WXWebpageObject webpage = new WXWebpageObject();  
    webpage.webpageUrl = "http://tv.csu.edu.cn/index.php?s=/Home/Article/detail/id/1857.html";  
    WXMediaMessage msg = new WXMediaMessage(webpage);  

    msg.title = "来自XX的分享"; 
    msg.description = "分享 XXadAndroid版";  

    SendMessageToWX.Req req = new SendMessageToWX.Req();  
    req.transaction = String.valueOf(System.currentTimeMillis());  
    req.message = msg;  
    req.scene = SendMessageToWX.Req.WXSceneSession; 
    wx_api.sendReq(req);  

}

public void weiChatShareCricle(){
    if (!wx_api.isWXAppInstalled()) {  
        Toast.makeText(WXPayEntryActivity.this, "您还未安装微信客户端",  
                Toast.LENGTH_SHORT).show();  
        return;  
    }  
    WXWebpageObject webpage = new WXWebpageObject();  
    webpage.webpageUrl = "http://baidu.com";  
    WXMediaMessage msg = new WXMediaMessage(webpage);  

    msg.title = "来自XX的分享"; 
    msg.description = "分享 XXadAndroid版";  

    SendMessageToWX.Req req = new SendMessageToWX.Req();  
    req.transaction = String.valueOf(System.currentTimeMillis());  
    req.message = msg;  
    req.scene = SendMessageToWX.Req.WXSceneTimeline; 
    wx_api.sendReq(req);  
}


@Override
public void onClick(View arg0) {
    switch (arg0.getId()) {
    case R.id.share_friend:
        weiChatShareFriend();
        break;
    case R.id.share_circle:
        weiChatShareCricle();
        break;
    case R.id.quxiao:
        finish();
        break;
    default:
        break;
    }
}
@Override  
public void onReq(BaseReq arg0) {  

}  



@Override  
public void onResp(BaseResp resp) {  
    String result = "";  
    switch (resp.errCode) {  
    case BaseResp.ErrCode.ERR_OK:  
        result = "errcode_success";  
        break;  
    case BaseResp.ErrCode.ERR_USER_CANCEL:  
        result = "errcode_cancel";  
        break;  
    case BaseResp.ErrCode.ERR_AUTH_DENIED:  
        result = "errcode_deny";  
        break;  
    default:  
        result = "errcode_unknown";  
        break;  
    }  
     Toast.makeText(this, result, Toast.LENGTH_LONG).show();  
} 
回调机制已经写上去了,但分享成功后没有出现“分享成功”的回调提示
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

3条回答 默认 最新

  • qq_30080223 qq_30080223 2015-07-24 03:36

    不知道不知道不知道不知道不知道不知道

    点赞 评论 复制链接分享
  • sina_2831808769 sina_2831808769 2015-07-25 05:38

    微信分享成功后回调问题

    点赞 评论 复制链接分享
  • u014231084 肥肉肉 2016-06-29 09:20

    这个问题解决了么?我也遇到了同样的问题

    点赞 评论 复制链接分享

相关推荐