Commit c51a6fd5c03573a65f7c1902432201182ed22d81
1 parent
bfd80f63f7
Exists in
master
modify uid from int to String
Showing 1 changed file with 1 additions and 1 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.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"); | 52 | payInfo.putString("serverId", "B4003"); |
53 | payInfo.putString("roleId", "10010"); | 53 | payInfo.putString("roleId", "10010"); |
54 | GumpSDK.pay(MainActivity.this, payInfo); | 54 | GumpSDK.pay(MainActivity.this, payInfo); |
55 | } | 55 | } |
56 | }); | 56 | }); |
57 | GumpSDK.init("10014", "7b9d31aa17b849b238ab79cef0733041", "301596413332339", "1000"); | 57 | GumpSDK.init("10014", "7b9d31aa17b849b238ab79cef0733041", "301596413332339", "1000"); |
58 | GumpSDK.start(this); | 58 | GumpSDK.start(this); |
59 | } | 59 | } |
60 | 60 | ||
61 | @Override | 61 | @Override |
62 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | 62 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
63 | Log.d("Main", "activity requestCode:" + requestCode + ",resultCode:" + resultCode); | 63 | Log.d("Main", "activity requestCode:" + requestCode + ",resultCode:" + resultCode); |
64 | if (requestCode == GumpSDK.LOGIN_REQUEST_CODE) { | 64 | if (requestCode == GumpSDK.LOGIN_REQUEST_CODE) { |
65 | if (resultCode == RESULT_OK) { | 65 | if (resultCode == RESULT_OK) { |
66 | int uid = data.getIntExtra("userId", -1); | 66 | String uid = data.getStringExtra("userId"); |
67 | int accountType = data.getIntExtra("accountType", -1); | 67 | int accountType = data.getIntExtra("accountType", -1); |
68 | String sessionkey = data.getStringExtra("sessionKey"); | 68 | String sessionkey = data.getStringExtra("sessionKey"); |
69 | userInfo.setText("userid:" + uid + ",accountType:" + accountType + ",sessionKey:" + sessionkey); | 69 | userInfo.setText("userid:" + uid + ",accountType:" + accountType + ",sessionKey:" + sessionkey); |
70 | btnLogout.setVisibility(View.VISIBLE); | 70 | btnLogout.setVisibility(View.VISIBLE); |
71 | if (accountType == GumpPreference.ACCOUNT_TYPE_QUICK_REG) | 71 | if (accountType == GumpPreference.ACCOUNT_TYPE_QUICK_REG) |
72 | btnBind.setVisibility(View.VISIBLE); | 72 | btnBind.setVisibility(View.VISIBLE); |
73 | } else if (resultCode == RESULT_CANCELED) { | 73 | } else if (resultCode == RESULT_CANCELED) { |
74 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 74 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
75 | } | 75 | } |
76 | } else if (requestCode == GumpSDK.PAY_REQUEST_CODE) { | 76 | } else if (requestCode == GumpSDK.PAY_REQUEST_CODE) { |
77 | if (resultCode == RESULT_OK) { | 77 | if (resultCode == RESULT_OK) { |
78 | int code = data.getIntExtra("code", -1); | 78 | int code = data.getIntExtra("code", -1); |
79 | String msg = data.getStringExtra("msg"); | 79 | String msg = data.getStringExtra("msg"); |
80 | int orderId = data.getIntExtra("orderId", -1); | 80 | int orderId = data.getIntExtra("orderId", -1); |
81 | String extraInfo = data.getStringExtra("extraInfo"); | 81 | String extraInfo = data.getStringExtra("extraInfo"); |
82 | Toast.makeText(this, "pay result: " + code + "," + msg + ",orderId:" + orderId + ",extraInfo:" + extraInfo, Toast.LENGTH_SHORT).show(); | 82 | Toast.makeText(this, "pay result: " + code + "," + msg + ",orderId:" + orderId + ",extraInfo:" + extraInfo, Toast.LENGTH_SHORT).show(); |
83 | } else if (resultCode == RESULT_CANCELED) { | 83 | } else if (resultCode == RESULT_CANCELED) { |
84 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 84 | Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
85 | } | 85 | } |
86 | } | 86 | } |
87 | super.onActivityResult(requestCode, resultCode, data); | 87 | super.onActivityResult(requestCode, resultCode, data); |
88 | } | 88 | } |
89 | 89 | ||
90 | @Override | 90 | @Override |
91 | public void onLogout() { | 91 | public void onLogout() { |
92 | btnLogout.setVisibility(View.GONE); | 92 | btnLogout.setVisibility(View.GONE); |
93 | if (btnBind.getVisibility() == View.VISIBLE) | 93 | if (btnBind.getVisibility() == View.VISIBLE) |
94 | btnBind.setVisibility(View.GONE); | 94 | btnBind.setVisibility(View.GONE); |
95 | userInfo.append(" is logout"); | 95 | userInfo.append(" is logout"); |
96 | } | 96 | } |
97 | 97 | ||
98 | } | 98 | } |
99 | 99 |