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();
}
回調機制已經寫上去了,但分享成功後沒有出現“分享成功”的回調提示
微信分享成功後回調問題
----------------------同志你好,我是CSDN問答機器人小N,奉組織之命為你提供參考答案,編程尚未成功,同志仍需努力!