|  |  | 
 |  |  |  | 
 |  |  | import android.app.Activity; | 
 |  |  | import android.os.Bundle; | 
 |  |  | import android.support.annotation.NonNull; | 
 |  |  | import android.widget.RelativeLayout; | 
 |  |  |  | 
 |  |  | import com.secondworld.sdk.GTGameApp; | 
 |  |  | import androidx.annotation.NonNull; | 
 |  |  |  | 
 |  |  | import com.secondworld.sdk.GTGameMain; | 
 |  |  | import com.secondworld.sdk.GameActivityProxy; | 
 |  |  | import com.secondworld.sdk.GameAppProxy; | 
 |  |  | import com.secondworld.sdk.UnityMsgHandler; | 
 |  |  | import com.secondworld.sdk.utils.CodeU2A; | 
 |  |  | import com.secondworld.sdk.utils.LogUtil; | 
 |  |  | import com.secondworld.sdk.utils.WebViewUtil; | 
 |  |  |  | 
 |  |  | import org.json.JSONException; | 
 |  |  | import org.json.JSONObject; | 
 |  |  |  | 
 |  |  | public class MainActivity extends Activity { | 
 |  |  |  | 
 |  |  |     private static Class<? extends GameActivityProxy> proxyClass; | 
 |  |  |     private static Class<? extends GameActivityProxy> proxyClass= GTGameMain.class; | 
 |  |  |  | 
 |  |  |     GameActivityProxy proxy; | 
 |  |  |  | 
 |  |  | 
 |  |  |     @Override | 
 |  |  |     protected void onCreate(Bundle savedInstanceState) { | 
 |  |  |         super.onCreate(savedInstanceState); | 
 |  |  |         GameAppProxy.isDemo=true; | 
 |  |  |         setContentView(R.layout.activity_main); | 
 |  |  |         RelativeLayout webContainer = findViewById(com.secondworld.sdk.R.id.webContainer); | 
 |  |  |         WebViewUtil.I.init(this, webContainer); | 
 |  |  |         try { | 
 |  |  |             if (proxyClass != null) { | 
 |  |  |                 proxy = proxyClass.newInstance(); | 
 |  |  | 
 |  |  |             e.printStackTrace(); | 
 |  |  |             LogUtil.e("GameActivity", e); | 
 |  |  |         } | 
 |  |  |         addEvent(); | 
 |  |  |         //addEvent(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void addEvent() | 
 |  |  |     { | 
 |  |  |     private void addEvent() { | 
 |  |  |         findViewById(R.id.login).setOnClickListener((v -> | 
 |  |  |         { | 
 |  |  |             JSONObject json = new JSONObject(); | 
 |  |  | 
 |  |  |         findViewById(R.id.pay).setOnClickListener((v -> { | 
 |  |  |             JSONObject json = new JSONObject(); | 
 |  |  |             try { | 
 |  |  |                 json.put("sid","10"); | 
 |  |  |                 json.put("serverName","bt2server"); | 
 |  |  |                 json.put("roleName","hahaha"); | 
 |  |  |                 json.put("roleID","123"); | 
 |  |  |                 json.put("money","110"); | 
 |  |  |                 json.put("vipLevel","5"); | 
 |  |  |                 json.put("level","10"); | 
 |  |  |                 json.put("familyName","hengha"); | 
 |  |  |                 json.put("createTime",""); | 
 |  |  |  | 
 |  |  |                 json.put("code", CodeU2A.PlatformPay); | 
 |  |  |                 json.put("cpInfo", System.currentTimeMillis()/1000+""); | 
 |  |  |                 json.put("orderId", System.currentTimeMillis()/1000+""); | 
 |  |  |                 json.put("cpInfo", "com.sanxiagame.zmjgp099"); | 
 |  |  |                 json.put("orderId", System.currentTimeMillis() / 1000 + ""); | 
 |  |  |                 json.put("sid", "1"); | 
 |  |  |                 json.put("roleID","test_role"); | 
 |  |  |                 json.put("title","goods_100"); | 
 |  |  |                 json.put("mount","0.01"); | 
 |  |  |                 json.put("roleID", "test_role"); | 
 |  |  |                 json.put("title", "goods_100"); | 
 |  |  |                 json.put("mount", "0.009999999776482582"); | 
 |  |  |             } catch (JSONException e) { | 
 |  |  |                 e.printStackTrace(); | 
 |  |  |             } | 
 |  |  |             UnityMsgHandler.onUnityMessage(json.toString()); | 
 |  |  |         })); | 
 |  |  |  | 
 |  |  |         findViewById(R.id.btnA).setOnClickListener(v -> { | 
 |  |  |             JSONObject json = new JSONObject(); | 
 |  |  |             try { | 
 |  |  |                 json.put("code", CodeU2A.RequestPermission); | 
 |  |  |                 json.put("permission", "android.permission.RECORD_AUDIO"); | 
 |  |  |             } catch (JSONException e) { | 
 |  |  |                 e.printStackTrace(); | 
 |  |  |             } | 
 |  |  |             UnityMsgHandler.onUnityMessage(json.toString()); | 
 |  |  |         }); | 
 |  |  |  | 
 |  |  |         findViewById(R.id.btnB).setOnClickListener(v -> { | 
 |  |  |             JSONObject json = new JSONObject(); | 
 |  |  |             try { | 
 |  |  |                 json.put("sid","bt2"); | 
 |  |  |                 json.put("serverName","bt2server"); | 
 |  |  |                 json.put("roleName","hahaha"); | 
 |  |  |                 json.put("roleID","123"); | 
 |  |  |                 json.put("money","110"); | 
 |  |  |                 json.put("vipLevel","5"); | 
 |  |  |                 json.put("level","10"); | 
 |  |  |                 json.put("familyName","hengha"); | 
 |  |  |                 json.put("createTime",""); | 
 |  |  |  | 
 |  |  |                 json.put("code", CodeU2A.CreateRole); | 
 |  |  |             } catch (JSONException e) { | 
 |  |  |                 e.printStackTrace(); | 
 |  |  |             } | 
 |  |  |             UnityMsgHandler.onUnityMessage(json.toString()); | 
 |  |  |         }); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void unityMessage(int code) { | 
 |  |  |         JSONObject json = new JSONObject(); | 
 |  |  |         try { | 
 |  |  |             json.put("code", code); | 
 |  |  |         } catch (JSONException e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |         UnityMsgHandler.onUnityMessage(json.toString()); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     protected void onStart() { | 
 |  |  |         super.onStart(); |