package com.example.gitnb.wxapi; import android.app.Activity; import android.os.Bundle; import android.widget.Toast; import com.tencent.mm.sdk.modelbase.BaseReq; import com.tencent.mm.sdk.modelbase.BaseResp; import com.tencent.mm.sdk.openapi.IWXAPI; import com.tencent.mm.sdk.openapi.IWXAPIEventHandler; import com.tencent.mm.sdk.openapi.WXAPIFactory; /** * Created by Rain on 16/4/17. */ public class WXEntryActivity extends Activity implements IWXAPIEventHandler { private IWXAPI api; @Override protected void onCreate(Bundle savedInstanceState) { api = WXAPIFactory.createWXAPI(this, WeiXin.AppID, false); api.handleIntent(getIntent(), this); super.onCreate(savedInstanceState); } @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(WXEntryActivity.this, result, Toast.LENGTH_LONG).show(); finish(); } }