开心武汉花 v1.0版本的 MD5 值为:50f08856f9e259845e47f8380bda4074

以下内容为反编译后的 WXEntryActivity.java 源代码,内容仅作参考


package whh.mjx.com.wxapi;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.JsonHttpResponseHandler;
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.modelmsg.SendMessageToWX;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.unity3d.player.UnityPlayer;
import org.apache.http.Header;
import org.json.JSONObject;
import whh.mjx.com.Constants;
import whh.mjx.com.WeChatLoginActivity;

public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
    private static final int TIMELINE_SUPPORTED_VERSION = 553779201;
    private IWXAPI api;
    private Button checkBtn;
    private Button gotoBtn;
    private AsyncHttpClient httpClient;
    private Button launchBtn;
    private Button regBtn;

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.httpClient = new AsyncHttpClient();
        IWXAPI createWXAPI = WXAPIFactory.createWXAPI(this, Constants.APP_ID, true);
        this.api = createWXAPI;
        createWXAPI.handleIntent(getIntent(), this);
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        this.api.handleIntent(intent, this);
    }

    @Override
    public void onReq(BaseReq baseReq) {
        baseReq.getType();
    }

    @Override
    public void onResp(BaseResp baseResp) {
        if (baseResp instanceof SendAuth.Resp) {
            if (baseResp.errCode == 0) {
                UnityPlayer.UnitySendMessage("Main Camera", "LoginCallBack", ((SendAuth.Resp) baseResp).code);
            }
        } else if ((baseResp instanceof SendMessageToWX.Resp) && baseResp.errCode == 0) {
            UnityPlayer.UnitySendMessage("Main Camera", "ShareCallBack", WeChatLoginActivity.CurrentScene + "");
        }
        finish();
    }

    private void getToken(String str) {
        this.httpClient.get("https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx3af8f8e85fca651f&secret=1f05357e9e0d38eb388ba32fd5461465&code=" + str + "&grant_type=authorization_code", new JsonHttpResponseHandler() {
            @Override
            public void onFailure(int i, Header[] headerArr, Throwable th, JSONObject jSONObject) {
            }

            @Override
            public void onSuccess(int i, Header[] headerArr, JSONObject jSONObject) {
                try {
                    String optString = jSONObject.optString("openid");
                    String optString2 = jSONObject.optString("access_token");
                    UnityPlayer.UnitySendMessage("Main Camera", "LoginCallBack", optString + "|@|" + optString2);
                    Toast.makeText(WXEntryActivity.this, optString + " " + optString2, 1).show();
                    WXEntryActivity.this.finish();
                } catch (Exception e) {
                    UnityPlayer.UnitySendMessage("Main Camera", "LoginCallBack", e.toString());
                    Toast.makeText(WXEntryActivity.this, e.toString(), 1).show();
                    WXEntryActivity.this.finish();
                }
            }
        });
    }

    private void getUserInfo(String str, String str2) {
        this.httpClient.get("https://api.weixin.qq.com/sns/userinfo?access_token=" + str + "&openid=" + str2, new JsonHttpResponseHandler() {
            @Override
            public void onFailure(int i, Header[] headerArr, Throwable th, JSONObject jSONObject) {
            }

            @Override
            public void onSuccess(int i, Header[] headerArr, JSONObject jSONObject) {
                UnityPlayer.UnitySendMessage("Main Camera", "LoginCallBack", jSONObject.optString("nickname") + " " + jSONObject.optInt("sex") + " " + jSONObject.optString("headimgurl"));
                WXEntryActivity.this.finish();
            }
        });
    }
}