Commit ad10e0999ed7de2fb2a412a6410d3d6c134fb93c
1 parent
d6a208e3c4
Exists in
master
update iosSDK to date
Showing 2 changed files with 2 additions and 2 deletions Inline Diff
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.GumpSDK; | 12 | import com.gumptech.sdk.GumpSDK; |
| 13 | 13 | ||
| 14 | public class MainActivity extends Activity implements GumpSDK.Callback { | 14 | public class MainActivity extends Activity implements GumpSDK.Callback { |
| 15 | 15 | ||
| 16 | private TextView tvVersion; | 16 | private TextView tvVersion; |
| 17 | private TextView userInfo; | 17 | private TextView userInfo; |
| 18 | 18 | ||
| 19 | private Button btnLoginOrLogout; | 19 | private Button btnLoginOrLogout; |
| 20 | 20 | ||
| 21 | private String appId = "10022"; | 21 | private String appId = "10021"; |
| 22 | 22 | ||
| 23 | @Override | 23 | @Override |
| 24 | protected void onCreate(Bundle savedInstanceState) { | 24 | protected void onCreate(Bundle savedInstanceState) { |
| 25 | super.onCreate(savedInstanceState); | 25 | super.onCreate(savedInstanceState); |
| 26 | setContentView(R.layout.activity_main); | 26 | setContentView(R.layout.activity_main); |
| 27 | tvVersion = (TextView) findViewById(R.id.version); | 27 | tvVersion = (TextView) findViewById(R.id.version); |
| 28 | userInfo = (TextView) findViewById(R.id.user_info); | 28 | userInfo = (TextView) findViewById(R.id.user_info); |
| 29 | btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); | 29 | btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); |
| 30 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { | 30 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { |
| 31 | 31 | ||
| 32 | @Override | 32 | @Override |
| 33 | public void onClick(View v) { | 33 | public void onClick(View v) { |
| 34 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) | 34 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) |
| 35 | GumpSDK.start(MainActivity.this); | 35 | GumpSDK.start(MainActivity.this); |
| 36 | else | 36 | else |
| 37 | GumpSDK.logout(MainActivity.this, MainActivity.this); | 37 | GumpSDK.logout(MainActivity.this, MainActivity.this); |
| 38 | } | 38 | } |
| 39 | }); | 39 | }); |
| 40 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { | 40 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { |
| 41 | 41 | ||
| 42 | @Override | 42 | @Override |
| 43 | public void onClick(View v) { | 43 | public void onClick(View v) { |
| 44 | Bundle payInfo = new Bundle(); | 44 | Bundle payInfo = new Bundle(); |
| 45 | payInfo.putString("nick", "thi"); | 45 | payInfo.putString("nick", "thi"); |
| 46 | payInfo.putString("product", "元宝"); | 46 | payInfo.putString("product", "元宝"); |
| 47 | payInfo.putFloat("amount", 0.0f); | 47 | payInfo.putFloat("amount", 0.0f); |
| 48 | payInfo.putString("extraInfo", "This is demo!"); | 48 | payInfo.putString("extraInfo", "This is demo!"); |
| 49 | payInfo.putString("serverId", "B4003"); | 49 | payInfo.putString("serverId", "B4003"); |
| 50 | payInfo.putString("roleId", "10010"); | 50 | payInfo.putString("roleId", "10010"); |
| 51 | GumpSDK.pay(MainActivity.this, payInfo); | 51 | GumpSDK.pay(MainActivity.this, payInfo); |
| 52 | } | 52 | } |
| 53 | }); | 53 | }); |
| 54 | GumpSDK.init(getApplicationContext(), appId, "93a27b0bd99bac3e68a440b48aa421ab", "1000"); | 54 | GumpSDK.init(getApplicationContext(), appId, "f702defbc67edb455949f46babab0c18", "1000"); |
| 55 | GumpSDK.setLogoShow(true); | 55 | GumpSDK.setLogoShow(true); |
| 56 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); | 56 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); |
| 57 | GumpSDK.start(this); | 57 | GumpSDK.start(this); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | @Override | 60 | @Override |
| 61 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | 61 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 62 | Log.d("Main", "activity requestCode:" + requestCode + ",resultCode:" + resultCode); | 62 | Log.d("Main", "activity requestCode:" + requestCode + ",resultCode:" + resultCode); |
| 63 | if (requestCode == GumpSDK.LOGIN_REQUEST_CODE) { | 63 | if (requestCode == GumpSDK.LOGIN_REQUEST_CODE) { |
| 64 | if (resultCode == RESULT_OK) { | 64 | if (resultCode == RESULT_OK) { |
| 65 | String uid = data.getStringExtra("userId"); | 65 | String uid = data.getStringExtra("userId"); |
| 66 | int accountType = data.getIntExtra("accountType", -1); | 66 | int accountType = data.getIntExtra("accountType", -1); |
| 67 | String sessionkey = data.getStringExtra("sessionKey"); | 67 | String sessionkey = data.getStringExtra("sessionKey"); |
| 68 | userInfo.setText(" userid:" + uid + "\n accountType:" + accountType + "\n sessionKey:" + sessionkey); | 68 | userInfo.setText(" userid:" + uid + "\n accountType:" + accountType + "\n sessionKey:" + sessionkey); |
| 69 | btnLoginOrLogout.setText("Logout"); | 69 | btnLoginOrLogout.setText("Logout"); |
| 70 | btnLoginOrLogout.setTag(1); | 70 | btnLoginOrLogout.setTag(1); |
| 71 | } else if (resultCode == RESULT_CANCELED) { | 71 | } else if (resultCode == RESULT_CANCELED) { |
| 72 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 72 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
| 73 | } | 73 | } |
| 74 | } else if (requestCode == GumpSDK.PAY_REQUEST_CODE) { | 74 | } else if (requestCode == GumpSDK.PAY_REQUEST_CODE) { |
| 75 | if (resultCode == RESULT_OK) { | 75 | if (resultCode == RESULT_OK) { |
| 76 | int code = data.getIntExtra("code", -1); | 76 | int code = data.getIntExtra("code", -1); |
| 77 | String msg = data.getStringExtra("msg"); | 77 | String msg = data.getStringExtra("msg"); |
| 78 | String orderId = data.getStringExtra("orderId"); | 78 | String orderId = data.getStringExtra("orderId"); |
| 79 | String extraInfo = data.getStringExtra("extraInfo"); | 79 | String extraInfo = data.getStringExtra("extraInfo"); |
| 80 | Toast.makeText(this, "pay result: " + code + "," + msg + ",orderId:" + orderId + ",extraInfo:" + extraInfo, Toast.LENGTH_SHORT).show(); | 80 | Toast.makeText(this, "pay result: " + code + "," + msg + ",orderId:" + orderId + ",extraInfo:" + extraInfo, Toast.LENGTH_SHORT).show(); |
| 81 | } else if (resultCode == RESULT_CANCELED) { | 81 | } else if (resultCode == RESULT_CANCELED) { |
| 82 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 82 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
| 83 | } | 83 | } |
| 84 | } | 84 | } |
| 85 | super.onActivityResult(requestCode, resultCode, data); | 85 | super.onActivityResult(requestCode, resultCode, data); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | @Override | 88 | @Override |
| 89 | public void onLogout() { | 89 | public void onLogout() { |
| 90 | btnLoginOrLogout.setText("Login"); | 90 | btnLoginOrLogout.setText("Login"); |
| 91 | btnLoginOrLogout.setTag(0); | 91 | btnLoginOrLogout.setTag(0); |
| 92 | userInfo.append("\n User is logout"); | 92 | userInfo.append("\n User is logout"); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | } | 95 | } |
| 96 | 96 |
ios/ios_20150215.zip
No preview for this file type