|
|
@@ -1,25 +1,34 @@
|
|
|
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 WXCallbackActivity {
|
|
|
+public class WXEntryActivity extends Activity 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);
|
|
|
finish();
|
|
|
}
|
|
|
|
|
|
@@ -27,10 +36,18 @@ public class WXEntryActivity extends WXCallbackActivity {
|
|
|
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);
|
|
|
finish();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public void onReq(BaseReq baseReq) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public void onResp(BaseResp resp) {
|
|
|
if (resp instanceof SendAuth.Resp) {
|
|
|
if (resp.errCode == BaseResp.ErrCode.ERR_OK) {
|
|
|
@@ -41,8 +58,6 @@ public class WXEntryActivity extends WXCallbackActivity {
|
|
|
Log.i("wx auth", "wx auth error");
|
|
|
EventBus.getDefault().post(new WXLoginAuthEvent(null));
|
|
|
}
|
|
|
- } else {
|
|
|
- super.onResp(resp);
|
|
|
}
|
|
|
}
|
|
|
|