1.0采用最新微信支付的SDK,在支付的回调页,当点击返回商家时,会出现界面闪动,并且会出现空白界面。
解决办法:
package com.hxrc.stocklegend.wxapi;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;
import com.hxrc.stocklegend.base.AppConfig;
import com.tencent.mm.opensdk.constants.ConstantsAPI;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
/**
* Created by pc on 2017/11/16.
*/
public class WXPayEntryActivity extends AppCompatActivity implements IWXAPIEventHandler {
private IWXAPI api;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
api = WXAPIFactory.createWXAPI(this, AppConfig.WEIXIN_APPID);
api.handleIntent(getIntent(), this);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
api.handleIntent(intent, this);
}
@Override
public void onReq(BaseReq req) {
}
@Override
public void onResp(BaseResp resp) {
if (resp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {
if (resp.errCode == 0) { // 支付成功
Toast.makeText(this, "支付成功", Toast.LENGTH_LONG).show();
finish();
} else if (resp.errCode == -1) { // 支付失败
Toast.makeText(this,
"支付失败", Toast.LENGTH_LONG).show();
finish();
} else if (resp.errCode == -2) { // 支付取消
Toast.makeText(this, "支付取消", Toast.LENGTH_LONG).show();
finish();
}
}
}
@Override
protected void onStop() {
super.onStop();
}
}
微信支付的SDK:
compile 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+'