|
|
@@ -1,31 +1,25 @@
|
|
|
package com.sheep.jiuyan.samllsheep.wxapi;
|
|
|
|
|
|
-import android.app.Activity;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.util.Log;
|
|
|
|
|
|
import com.sheep.gamegroup.event.WXLoginAuthEvent;
|
|
|
-import com.sheep.gamegroup.util.LogUtil;
|
|
|
import com.sheep.jiuyan.samllsheep.Config;
|
|
|
-import com.sheep.jiuyan.samllsheep.wxutil.WXAPIUtil;
|
|
|
import com.tencent.mm.opensdk.modelbase.BaseReq;
|
|
|
import com.tencent.mm.opensdk.modelbase.BaseResp;
|
|
|
import com.tencent.mm.opensdk.modelmsg.SendAuth;
|
|
|
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
|
|
-import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
|
|
|
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
|
|
import com.umeng.socialize.weixin.view.WXCallbackActivity;
|
|
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
|
|
|
-public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
|
|
|
+public class WXEntryActivity extends WXCallbackActivity {//implements IWXAPIEventHandler
|
|
|
|
|
|
@Override
|
|
|
public void onCreate(Bundle bundle) {
|
|
|
super.onCreate(bundle);
|
|
|
- Log.i("wx auth", "wx auth intent");
|
|
|
-// WXAPIUtil.handle(this, getIntent());
|
|
|
IWXAPI wxapi = WXAPIFactory.createWXAPI(this, Config.WX_AUTH_APP_ID, true);
|
|
|
wxapi.registerApp(Config.WX_AUTH_APP_ID);
|
|
|
wxapi.handleIntent(getIntent(), this);
|
|
|
@@ -34,8 +28,6 @@ public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
|
|
|
|
|
|
@Override
|
|
|
public void onNewIntent(Intent newIntent) {
|
|
|
- Log.i("wx auth", "wx auth new intent");
|
|
|
-// WXAPIUtil.handle(this, newIntent);
|
|
|
IWXAPI wxapi = WXAPIFactory.createWXAPI(this, Config.WX_AUTH_APP_ID, true);
|
|
|
wxapi.registerApp(Config.WX_AUTH_APP_ID);
|
|
|
wxapi.handleIntent(getIntent(), this);
|
|
|
@@ -44,20 +36,22 @@ public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
|
|
|
|
|
|
@Override
|
|
|
public void onReq(BaseReq baseReq) {
|
|
|
-
|
|
|
+ if(!(baseReq instanceof SendAuth.Req)){
|
|
|
+ super.onReq(baseReq);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onResp(BaseResp resp) {
|
|
|
if (resp instanceof SendAuth.Resp) {
|
|
|
if (resp.errCode == BaseResp.ErrCode.ERR_OK) {
|
|
|
- Log.i("wx auth", "wx auth ok");
|
|
|
String code = ((SendAuth.Resp) resp).code;
|
|
|
EventBus.getDefault().post(new WXLoginAuthEvent(code));
|
|
|
} else{
|
|
|
- Log.i("wx auth", "wx auth error");
|
|
|
EventBus.getDefault().post(new WXLoginAuthEvent(null));
|
|
|
}
|
|
|
+ } else {
|
|
|
+ super.onResp(resp);
|
|
|
}
|
|
|
}
|
|
|
|