package com.example.pluginmain.wxapi;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
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{
public static final String APP_ID = "wx8ce466b2fc952d31";
private IWXAPI api;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
api = WXAPIFactory.createWXAPI(this, APP_ID, false);
api.handleIntent(getIntent(), this);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
api.handleIntent(intent, this);
}
@Override
public void onReq(BaseReq baseReq) {
//nothing
}
@Override
public void onResp(BaseResp resp) {
String result = "";
switch (resp.errCode) {
case BaseResp.ErrCode.ERR_OK:
result = "发送成功";
break;
case BaseResp.ErrCode.ERR_USER_CANCEL:
result = "发送取消";
break;
case BaseResp.ErrCode.ERR_AUTH_DENIED:
result = "发送被拒绝";
break;
case -6:
result = "发送时使用的context的packageName不是宿主的会导致了-6";
break;
default:
result = "发送返回";
break;
}
Toast.makeText(this, result, Toast.LENGTH_LONG).show();
finish();
}
}