导航菜单

页面标题

页面副标题

同欣武汉花 v1.1 - WXEntryActivity.java 源代码

正在查看: 同欣武汉花 v1.1 应用的 WXEntryActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package kx.sports.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 kx.sports.com.Constants;
import kx.sports.com.WeChatLoginActivity;
import org.apache.http.Header;
import org.json.JSONObject;

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, false);
        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=wxa7bfa96741d7c16b&secret=&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();
            }
        });
    }
}