Files
July/app/src/main/java/com/fenghoo/seven/wxapi/WXPayEntryActivity.java
2020-08-25 10:08:00 +08:00

68 lines
1.6 KiB
Java

package com.fenghoo.seven.wxapi;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import com.fenghoo.seven.base.BaseActivity;
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 androidx.annotation.Nullable;
/**
* 微信支付回调页
*/
public class WXPayEntryActivity extends BaseActivity implements IWXAPIEventHandler {
private IWXAPI api;
private TextView mTextView;
private Intent intent;
@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.errCode == 0) {
toast("支付成功");
} else if (resp.errCode == -1) {
toast("支付失败");
} else if (resp.errCode == -2) {
toast("取消支付");
}
/**
* 用广播发出回掉状态
*/
intent = new Intent();
intent.setAction("com.antiphon.BroadcastReceiver");
intent.putExtra("payCode",resp.errCode);
sendBroadcast(intent);
finish();
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initData();
}
private void initData() {
// api = WXAPIFactory.createWXAPI(this, PayUtils.APP_ID);
api.handleIntent(getIntent(), this);
}
}