WXEntryActivity

                       

写法一:

import com.tencent.mm.sdk.modelbase.BaseReq;import com.tencent.mm.sdk.modelbase.BaseResp;import com.tencent.mm.sdk.modelmsg.SendAuth;import com.tencent.mm.sdk.openapi.IWXAPI;import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;import com.tencent.mm.sdk.openapi.WXAPIFactory;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.util.Log;public class WXEntryActivity extends Activity implements IWXAPIEventHandler {    private IWXAPI api;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        Log.e("WXEntryActivity", "onCreate");        api = WXAPIFactory.createWXAPI(this, APP_ID_WECHAT, false);        api.registerApp(APP_ID_WECHAT);          handleIntent(getIntent());    }    @Override    protected void onNewIntent(Intent intent) {        super.onNewIntent(intent);        Log.e("WXEntryActivity", "onNewIntent");        handleIntent(intent);    }    private void handleIntent(Intent intent) {        setIntent(intent);        api.handleIntent(intent, this);    }    @Override    public void onReq(BaseReq arg0) {        // TODO Auto-generated method stub        Log.e("WXEntryActivity", "onReq");    }    @Override    public void onResp(BaseResp resp) {        Log.e("WXEntryActivity", "onResp");        // TODO Auto-generated method stub        if (resp.errCode == BaseResp.ErrCode.ERR_OK) {            // 用户同意            Log.e("WXEntryActivity", "onResp" + resp.errCode);            Log.e("WXEntryActivity", "onResp" + resp.errStr);            Log.e("WXEntryActivity", "onResp" + resp.openId);        }    }}
  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55

写法二:

import com.tencent.mm.sdk.modelbase.BaseResp;import com.tencent.mm.sdk.modelmsg.SendAuth;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.util.Log;public class WXEntryActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        Log.e("WXEntryActivity", "onCreate");        handleIntent(getIntent());    }    @Override    protected void onNewIntent(Intent intent) {        super.onNewIntent(intent);        Log.e("WXEntryActivity", "onNewIntent");        handleIntent(intent);    }    private void handleIntent(Intent intent) {        SendAuth.Resp resp = new SendAuth.Resp(intent.getExtras());        if (resp.errCode == BaseResp.ErrCode.ERR_OK) {            Log.e("WXEntryActivity", "handleIntent" + resp.errCode);            Log.e("WXEntryActivity", "handleIntent" + resp.errStr);            Log.e("WXEntryActivity", "handleIntent" + resp.openId);            Log.e("WXEntryActivity", "handleIntent" + resp.code);        }    }}
  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
           
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值