WXEntryActivity.java
2.29 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.tencent.youai.shushan.wxapi;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import com.tencent.mm.sdk.modelbase.BaseReq;
import com.tencent.mm.sdk.modelbase.BaseResp;
import com.tencent.mm.sdk.modelmsg.SendAuth.Resp;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
import com.youai.sdk.YouaiSDK;
public class WXEntryActivity extends Activity implements IWXAPIEventHandler{
private static final String TAG = "MicroMsg.SDKSample.WXEntryActivity";
private IWXAPI api;
private Handler checkLoginHandler = new Handler(){
public void handleMessage(android.os.Message msg) {
YouaiSDK.open_url((String) msg.obj);
};
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
api = WXAPIFactory.createWXAPI(this, YouaiSDK.weixinAppId);
api.handleIntent(getIntent(), this);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
api.handleIntent(intent, this);
}
@Override
public void onReq(BaseReq arg0) {
// TODO Auto-generated method stub
}
@Override
public void onResp(BaseResp resp) {
Log.d(TAG, "0成功,-1错误,-2用户取消 onLoginFinish, errCode = " + resp.errCode);
if (YouaiSDK.lastCallBack != null) {
if(resp.errCode == 0){
if(resp instanceof Resp) {
Resp var7 = (Resp)resp;
Log.d("YSDK_USER_WX", "code: " + var7.code);
Message msg = Message.obtain();
msg.obj = var7.code;
checkLoginHandler.sendMessageDelayed(msg , 3000);
//YouaiSDK.open_url(var7.code);
}else{
Intent i = new Intent();
i.putExtra("msg", "充值成功");
YouaiSDK.lastCallBack.onEventDispatch(YouaiSDK.PAY_ACTION_CODE, i);
}
// YouaiSDK.lastCallBack.onEventDispatch(YouaiSDK.PAY_ACTION_CODE, i);
}else if(resp.errCode == -2){
Intent i = new Intent();
i.putExtra("msg", "用户取消");
YouaiSDK.lastCallBack.onEventDispatch(YouaiSDK.PAY_ACTION_CODE, i);
}
}
finish();
}
}