Blame view
android/GameSDKSample/src/com/gumptech/loginsdk/sample/MainActivity.java
3.36 KB
|
dd679641e
|
1 2 3 4 5 6 7 8 9 10 11 12 |
package com.gumptech.loginsdk.sample; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import com.gumptech.sdk.GumpSDK; |
|
09d4c173f
|
13 |
import com.loginsdk.sample.R; |
|
dd679641e
|
14 15 16 17 18 19 20 |
public class MainActivity extends Activity implements GumpSDK.Callback {
private TextView tvVersion;
private TextView userInfo;
private Button btnLoginOrLogout;
|
|
c69691da8
|
21 |
private String appId = "10022"; |
|
dd679641e
|
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tvVersion = (TextView) findViewById(R.id.version);
userInfo = (TextView) findViewById(R.id.user_info);
btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout);
btnLoginOrLogout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0)
GumpSDK.start(MainActivity.this);
else
GumpSDK.logout(MainActivity.this, MainActivity.this);
}
});
findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle payInfo = new Bundle();
payInfo.putString("nick", "thi");
payInfo.putString("product", "元宝");
payInfo.putFloat("amount", 0.0f);
payInfo.putString("extraInfo", "This is demo!");
|
|
09d4c173f
|
49 50 |
payInfo.putString("serverId", "5001");
payInfo.putString("roleId", "41081");
|
|
359f62c6d
|
51 |
GumpSDK.pay(MainActivity.this, payInfo,"3332768"); |
|
dd679641e
|
52 53 |
} }); |
|
09d4c173f
|
54 |
GumpSDK.init(getApplicationContext(), appId, "93a27b0bd99bac3e68a440b48aa421ab", "1000"); |
|
dd679641e
|
55 |
GumpSDK.setLogoShow(true); |
|
359f62c6d
|
56 |
GumpSDK.setScreenLandscape(true); |
|
dd679641e
|
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
tvVersion.setText("SDK Version:" + GumpSDK.getVersion());
GumpSDK.start(this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d("Main", "activity requestCode:" + requestCode + ",resultCode:" + resultCode);
if (requestCode == GumpSDK.LOGIN_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
String uid = data.getStringExtra("userId");
int accountType = data.getIntExtra("accountType", -1);
String sessionkey = data.getStringExtra("sessionKey");
userInfo.setText(" userid:" + uid + "
accountType:" + accountType + "
sessionKey:" + sessionkey);
btnLoginOrLogout.setText("Logout");
btnLoginOrLogout.setTag(1);
} else if (resultCode == RESULT_CANCELED) {
Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show();
}
|
|
359f62c6d
|
77 78 79 80 81 82 83 84 85 86 87 88 89 |
}
// @Deprecated
// else if (requestCode == GumpSDK.PAY_REQUEST_CODE) {
// if (resultCode == RESULT_OK) {
// int code = data.getIntExtra("code", -1);
// String msg = data.getStringExtra("msg");
// String orderId = data.getStringExtra("orderId");
// String extraInfo = data.getStringExtra("extraInfo");
// Toast.makeText(this, "pay result: " + code + "," + msg + ",orderId:" + orderId + ",extraInfo:" + extraInfo, Toast.LENGTH_SHORT).show();
// } else if (resultCode == RESULT_CANCELED) {
// Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show();
// }
// }
|
|
dd679641e
|
90 91 92 93 94 95 96 97 98 99 100 101 |
super.onActivityResult(requestCode, resultCode, data);
}
@Override
public void onLogout() {
btnLoginOrLogout.setText("Login");
btnLoginOrLogout.setTag(0);
userInfo.append("
User is logout");
}
}
|