Commit e4307bd087860b5571f775ec6a78aa7de5a56a89
1 parent
53dd88a4db
Exists in
master
modify the method of init
Showing 2 changed files with 4 additions and 2 deletions Inline Diff
android/GameSDKRelease/libs/GameSDK_proguard_v2.0.jar
No preview for this file type
android/GameSDKSample/src/com/gumptech/loginsdk/sample/MainActivity.java
| 1 | package com.gumptech.loginsdk.sample; | 1 | package com.gumptech.loginsdk.sample; |
| 2 | 2 | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | import android.content.Intent; | 4 | import android.content.Intent; |
| 5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
| 6 | import android.util.Log; | 6 | import android.util.Log; |
| 7 | import android.view.View; | 7 | import android.view.View; |
| 8 | import android.widget.Button; | 8 | import android.widget.Button; |
| 9 | import android.widget.TextView; | 9 | import android.widget.TextView; |
| 10 | import android.widget.Toast; | 10 | import android.widget.Toast; |
| 11 | 11 | ||
| 12 | import com.gumptech.sdk.GumpPreference; | 12 | import com.gumptech.sdk.GumpPreference; |
| 13 | import com.gumptech.sdk.GumpSDK; | 13 | import com.gumptech.sdk.GumpSDK; |
| 14 | 14 | ||
| 15 | public class MainActivity extends Activity implements GumpSDK.Callback { | 15 | public class MainActivity extends Activity implements GumpSDK.Callback { |
| 16 | 16 | ||
| 17 | private TextView userInfo; | 17 | private TextView userInfo; |
| 18 | 18 | ||
| 19 | private Button btnLogout; | 19 | private Button btnLogout; |
| 20 | private Button btnBind; | 20 | private Button btnBind; |
| 21 | 21 | ||
| 22 | @Override | 22 | @Override |
| 23 | protected void onCreate(Bundle savedInstanceState) { | 23 | protected void onCreate(Bundle savedInstanceState) { |
| 24 | super.onCreate(savedInstanceState); | 24 | super.onCreate(savedInstanceState); |
| 25 | setContentView(R.layout.activity_main); | 25 | setContentView(R.layout.activity_main); |
| 26 | userInfo = (TextView) findViewById(R.id.user_info); | 26 | userInfo = (TextView) findViewById(R.id.user_info); |
| 27 | btnLogout = (Button) findViewById(R.id.logout); | 27 | btnLogout = (Button) findViewById(R.id.logout); |
| 28 | btnBind = (Button) findViewById(R.id.bind); | 28 | btnBind = (Button) findViewById(R.id.bind); |
| 29 | btnLogout.setOnClickListener(new View.OnClickListener() { | 29 | btnLogout.setOnClickListener(new View.OnClickListener() { |
| 30 | 30 | ||
| 31 | @Override | 31 | @Override |
| 32 | public void onClick(View v) { | 32 | public void onClick(View v) { |
| 33 | GumpSDK.logout(MainActivity.this, MainActivity.this); | 33 | GumpSDK.logout(MainActivity.this, MainActivity.this); |
| 34 | } | 34 | } |
| 35 | }); | 35 | }); |
| 36 | btnBind.setOnClickListener(new View.OnClickListener() { | 36 | btnBind.setOnClickListener(new View.OnClickListener() { |
| 37 | 37 | ||
| 38 | @Override | 38 | @Override |
| 39 | public void onClick(View v) { | 39 | public void onClick(View v) { |
| 40 | GumpSDK.boundMail(MainActivity.this); | 40 | GumpSDK.boundMail(MainActivity.this); |
| 41 | } | 41 | } |
| 42 | }); | 42 | }); |
| 43 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { | 43 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { |
| 44 | 44 | ||
| 45 | @Override | 45 | @Override |
| 46 | public void onClick(View v) { | 46 | public void onClick(View v) { |
| 47 | Bundle payInfo = new Bundle(); | 47 | Bundle payInfo = new Bundle(); |
| 48 | payInfo.putString("nick", "thi"); | 48 | payInfo.putString("nick", "thi"); |
| 49 | payInfo.putString("product", "元宝"); | 49 | payInfo.putString("product", "元宝"); |
| 50 | payInfo.putFloat("amount", 0.0f); | 50 | payInfo.putFloat("amount", 0.0f); |
| 51 | payInfo.putString("extraInfo", "This is demo!"); | 51 | payInfo.putString("extraInfo", "This is demo!"); |
| 52 | payInfo.putString("serverId", "B4003"); | ||
| 53 | payInfo.putString("roleId", "10010"); | ||
| 52 | GumpSDK.pay(MainActivity.this, payInfo); | 54 | GumpSDK.pay(MainActivity.this, payInfo); |
| 53 | } | 55 | } |
| 54 | }); | 56 | }); |
| 55 | GumpSDK.init("10009", "483d8df877b31405c1e8fe4247f02d86", "301596413332339", "1000", "4003", "120"); | 57 | GumpSDK.init("10014", "7b9d31aa17b849b238ab79cef0733041", "301596413332339", "1000"); |
| 56 | GumpSDK.start(this); | 58 | GumpSDK.start(this); |
| 57 | } | 59 | } |
| 58 | 60 | ||
| 59 | @Override | 61 | @Override |
| 60 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | 62 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 61 | Log.d("Main", "activity requestCode:" + requestCode + ",resultCode:" + resultCode); | 63 | Log.d("Main", "activity requestCode:" + requestCode + ",resultCode:" + resultCode); |
| 62 | if (requestCode == GumpSDK.LOGIN_REQUEST_CODE) { | 64 | if (requestCode == GumpSDK.LOGIN_REQUEST_CODE) { |
| 63 | if (resultCode == RESULT_OK) { | 65 | if (resultCode == RESULT_OK) { |
| 64 | int uid = data.getIntExtra("userId", -1); | 66 | int uid = data.getIntExtra("userId", -1); |
| 65 | int accountType = data.getIntExtra("accountType", -1); | 67 | int accountType = data.getIntExtra("accountType", -1); |
| 66 | String sessionkey = data.getStringExtra("sessionKey"); | 68 | String sessionkey = data.getStringExtra("sessionKey"); |
| 67 | userInfo.setText("userid:" + uid + ",accountType:" + accountType + ",sessionKey:" + sessionkey); | 69 | userInfo.setText("userid:" + uid + ",accountType:" + accountType + ",sessionKey:" + sessionkey); |
| 68 | btnLogout.setVisibility(View.VISIBLE); | 70 | btnLogout.setVisibility(View.VISIBLE); |
| 69 | if (accountType == GumpPreference.ACCOUNT_TYPE_QUICK_REG) | 71 | if (accountType == GumpPreference.ACCOUNT_TYPE_QUICK_REG) |
| 70 | btnBind.setVisibility(View.VISIBLE); | 72 | btnBind.setVisibility(View.VISIBLE); |
| 71 | } else if (resultCode == RESULT_CANCELED) { | 73 | } else if (resultCode == RESULT_CANCELED) { |
| 72 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 74 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
| 73 | } | 75 | } |
| 74 | } else if (requestCode == GumpSDK.BOUND_REQUEST_CODE) { | 76 | } else if (requestCode == GumpSDK.BOUND_REQUEST_CODE) { |
| 75 | if (resultCode == RESULT_OK) { | 77 | if (resultCode == RESULT_OK) { |
| 76 | int uid = data.getIntExtra("userId", -1); | 78 | int uid = data.getIntExtra("userId", -1); |
| 77 | int accountType = data.getIntExtra("accountType", -1); | 79 | int accountType = data.getIntExtra("accountType", -1); |
| 78 | String sessionkey = data.getStringExtra("sessionKey"); | 80 | String sessionkey = data.getStringExtra("sessionKey"); |
| 79 | userInfo.setText("userid:" + uid + ",accountType:" + accountType + ",sessionKey:" + sessionkey); | 81 | userInfo.setText("userid:" + uid + ",accountType:" + accountType + ",sessionKey:" + sessionkey); |
| 80 | btnBind.setVisibility(View.GONE); | 82 | btnBind.setVisibility(View.GONE); |
| 81 | } else if (resultCode == RESULT_CANCELED) { | 83 | } else if (resultCode == RESULT_CANCELED) { |
| 82 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 84 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
| 83 | } | 85 | } |
| 84 | } else if (requestCode == GumpSDK.PAY_REQUEST_CODE) { | 86 | } else if (requestCode == GumpSDK.PAY_REQUEST_CODE) { |
| 85 | if (resultCode == RESULT_OK) { | 87 | if (resultCode == RESULT_OK) { |
| 86 | int code = data.getIntExtra("code", -1); | 88 | int code = data.getIntExtra("code", -1); |
| 87 | String msg = data.getStringExtra("msg"); | 89 | String msg = data.getStringExtra("msg"); |
| 88 | int orderId = data.getIntExtra("orderId", -1); | 90 | int orderId = data.getIntExtra("orderId", -1); |
| 89 | String extraInfo = data.getStringExtra("extraInfo"); | 91 | String extraInfo = data.getStringExtra("extraInfo"); |
| 90 | Toast.makeText(this, "pay result: " + code + "," + msg + ",orderId:" + orderId + ",extraInfo:" + extraInfo, Toast.LENGTH_SHORT).show(); | 92 | Toast.makeText(this, "pay result: " + code + "," + msg + ",orderId:" + orderId + ",extraInfo:" + extraInfo, Toast.LENGTH_SHORT).show(); |
| 91 | } else if (resultCode == RESULT_CANCELED) { | 93 | } else if (resultCode == RESULT_CANCELED) { |
| 92 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 94 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
| 93 | } | 95 | } |
| 94 | } | 96 | } |
| 95 | super.onActivityResult(requestCode, resultCode, data); | 97 | super.onActivityResult(requestCode, resultCode, data); |
| 96 | } | 98 | } |
| 97 | 99 | ||
| 98 | @Override | 100 | @Override |
| 99 | public void onLogout() { | 101 | public void onLogout() { |
| 100 | btnLogout.setVisibility(View.GONE); | 102 | btnLogout.setVisibility(View.GONE); |
| 101 | if (btnBind.getVisibility() == View.VISIBLE) | 103 | if (btnBind.getVisibility() == View.VISIBLE) |
| 102 | btnBind.setVisibility(View.GONE); | 104 | btnBind.setVisibility(View.GONE); |
| 103 | userInfo.append(" is logout"); | 105 | userInfo.append(" is logout"); |
| 104 | } | 106 | } |
| 105 | 107 | ||
| 106 | } | 108 | } |
| 107 | 109 |