Commit d42a066802cdec2911b2b7c27c603b2580a579b4
1 parent
c51ca89cac
Exists in
master
remove wechat login type,add initialize button
Showing 6 changed files with 39 additions and 62 deletions Inline Diff
GameSDKDemo/build.gradle
1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
2 | 2 | ||
3 | /*gump test config,you could ignore it | 3 | /*gump test config,you could ignore it |
4 | * gump打包测试使用,你可以自行配置,或者直接删除这部分内容 | 4 | * gump打包测试使用,你可以自行配置,或者直接删除这部分内容 |
5 | */ | 5 | */ |
6 | def keystorePSW = '' | 6 | def keystorePSW = '' |
7 | def keystoreAlias = '' | 7 | def keystoreAlias = '' |
8 | def keystoreAliasPSW = '' | 8 | def keystoreAliasPSW = '' |
9 | // default keystore file, PLZ config file path in local.properties | 9 | // default keystore file, PLZ config file path in local.properties |
10 | def keyfile = file('s.keystore.temp') | 10 | def keyfile = file('s.keystore.temp') |
11 | 11 | ||
12 | Properties properties = new Properties() | 12 | Properties properties = new Properties() |
13 | // local.properties file in the root director | 13 | // local.properties file in the root director |
14 | properties.load(project.file('local.properties').newDataInputStream()) | 14 | properties.load(project.file('local.properties').newDataInputStream()) |
15 | def keystoreFilepath = properties.getProperty("keystore.path") | 15 | def keystoreFilepath = properties.getProperty("keystore.path") |
16 | 16 | ||
17 | if (keystoreFilepath) { | 17 | if (keystoreFilepath) { |
18 | keystorePSW = properties.getProperty("keystore.password") | 18 | keystorePSW = properties.getProperty("keystore.password") |
19 | keystoreAlias = properties.getProperty("keystore.alias") | 19 | keystoreAlias = properties.getProperty("keystore.alias") |
20 | keystoreAliasPSW = properties.getProperty("keystore.key_passwd") | 20 | keystoreAliasPSW = properties.getProperty("keystore.key_passwd") |
21 | keyfile = file(keystoreFilepath) | 21 | keyfile = file(keystoreFilepath) |
22 | } | 22 | } |
23 | /* | 23 | /* |
24 | * gump test config,you could ignore it | 24 | * gump test config,you could ignore it |
25 | * gump打包测试使用,你可以自行配置,或者直接删除这部分内容 | 25 | * gump打包测试使用,你可以自行配置,或者直接删除这部分内容 |
26 | */ | 26 | */ |
27 | 27 | ||
28 | repositories { | 28 | repositories { |
29 | maven{ | 29 | maven{ |
30 | url "http://117.50.8.198:8081/nexus/content/repositories/sdk" | 30 | url "http://117.50.8.198:8081/nexus/content/repositories/sdk" |
31 | } | 31 | } |
32 | jcenter() | 32 | jcenter() |
33 | google() | 33 | google() |
34 | } | 34 | } |
35 | 35 | ||
36 | android { | 36 | android { |
37 | compileSdkVersion 26 | 37 | compileSdkVersion 26 |
38 | buildToolsVersion "27.0.3" | 38 | buildToolsVersion "27.0.3" |
39 | 39 | ||
40 | signingConfigs { | 40 | signingConfigs { |
41 | release { | 41 | release { |
42 | storeFile keyfile | 42 | storeFile keyfile |
43 | storePassword keystorePSW | 43 | storePassword keystorePSW |
44 | keyPassword keystoreAliasPSW | 44 | keyPassword keystoreAliasPSW |
45 | keyAlias keystoreAlias | 45 | keyAlias keystoreAlias |
46 | } | 46 | } |
47 | } | 47 | } |
48 | 48 | ||
49 | defaultConfig { | 49 | defaultConfig { |
50 | minSdkVersion 14 | 50 | minSdkVersion 14 |
51 | targetSdkVersion 26 | 51 | targetSdkVersion 26 |
52 | versionCode 5 | 52 | versionCode 5 |
53 | versionName "1.3" | 53 | versionName "1.3" |
54 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | 54 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
55 | signingConfig signingConfigs.release | 55 | signingConfig signingConfigs.release |
56 | } | 56 | } |
57 | buildTypes { | 57 | buildTypes { |
58 | release { | 58 | release { |
59 | minifyEnabled false | 59 | minifyEnabled false |
60 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | 60 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
61 | zipAlignEnabled true | 61 | zipAlignEnabled true |
62 | } | 62 | } |
63 | debug { | 63 | debug { |
64 | signingConfig signingConfigs.release | 64 | signingConfig signingConfigs.release |
65 | } | 65 | } |
66 | } | 66 | } |
67 | lintOptions { | 67 | lintOptions { |
68 | abortOnError false | 68 | abortOnError false |
69 | } | 69 | } |
70 | 70 | ||
71 | } | 71 | } |
72 | 72 | ||
73 | dependencies { | 73 | dependencies { |
74 | implementation fileTree(include: ['*.jar'], dir: 'libs') | 74 | implementation fileTree(include: ['*.jar'], dir: 'libs') |
75 | testImplementation 'junit:junit:4.12' | 75 | testImplementation 'junit:junit:4.12' |
76 | implementation 'com.android.support:appcompat-v7:26.1.0' | 76 | implementation 'com.android.support:appcompat-v7:26.1.0' |
77 | //微信 | 77 | //微信 |
78 | implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.1.4' | 78 | implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.1.4' |
79 | //VK | 79 | //VK |
80 | implementation 'com.gumptech:VKsdk:1.5.4' | 80 | implementation 'com.gumptech:VKsdk:1.5.4' |
81 | // implementation project(':GameSDK') | 81 | // implementation project(':GameSDK') |
82 | implementation 'com.gumptech.sdk:GameSDK:4.5.6' | 82 | implementation 'com.gumptech.sdk:GameSDK:4.5.8' |
83 | } | 83 | } |
84 | 84 |
GameSDKDemo/src/main/AndroidManifest.xml
1 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
2 | package="com.gumptech.sdk.demo"> | 2 | package="com.gumptech.sdk.demo"> |
3 | 3 | ||
4 | 4 | ||
5 | <uses-sdk | 5 | <uses-sdk |
6 | android:minSdkVersion="9" | 6 | android:minSdkVersion="9" |
7 | android:targetSdkVersion="23"/> | 7 | android:targetSdkVersion="23"/> |
8 | 8 | ||
9 | <uses-permission android:name="android.permission.INTERNET"/> | 9 | <uses-permission android:name="android.permission.INTERNET"/> |
10 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> | 10 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> |
11 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | 11 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> |
12 | <!-- Danger Level permission--> | 12 | <!-- Danger Level permission--> |
13 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
14 | 13 | ||
15 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> | 14 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> |
16 | <uses-permission android:name="com.android.vending.BILLING"/> | 15 | <uses-permission android:name="com.android.vending.BILLING"/> |
17 | 16 | ||
18 | <application | 17 | <application |
19 | android:allowBackup="true" | 18 | android:allowBackup="true" |
20 | android:icon="@drawable/ic_launcher" | 19 | android:icon="@drawable/ic_launcher" |
21 | android:label="@string/app_name"> | 20 | android:label="@string/app_name"> |
22 | <activity | 21 | <activity |
23 | android:name="com.gumptech.sdk.demo.MainActivity" | 22 | android:name="com.gumptech.sdk.demo.MainActivity" |
24 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 23 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
25 | android:label="@string/app_name" | 24 | android:label="@string/app_name" |
26 | android:screenOrientation="landscape"> | 25 | android:screenOrientation="landscape"> |
27 | <intent-filter> | 26 | <intent-filter> |
28 | <action android:name="android.intent.action.MAIN"/> | 27 | <action android:name="android.intent.action.MAIN"/> |
29 | 28 | ||
30 | <category android:name="android.intent.category.LAUNCHER"/> | 29 | <category android:name="android.intent.category.LAUNCHER"/> |
31 | </intent-filter> | 30 | </intent-filter> |
32 | </activity> | 31 | </activity> |
33 | <activity | 32 | <activity |
34 | android:name="com.gumptech.sdk.ContainerActivity" | 33 | android:name="com.gumptech.sdk.ContainerActivity" |
35 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 34 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
36 | android:launchMode="singleTask" | 35 | android:launchMode="singleTask" |
37 | android:theme="@style/Theme.TransparentWin" | 36 | android:theme="@style/Theme.TransparentWin" |
38 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan"> | 37 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan"> |
39 | </activity> | 38 | </activity> |
40 | <activity | 39 | <activity |
41 | android:name="com.gumptech.sdk.PaymentActivity" | 40 | android:name="com.gumptech.sdk.PaymentActivity" |
42 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 41 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
43 | android:launchMode="singleTask" | 42 | android:launchMode="singleTask" |
44 | android:theme="@android:style/Theme.Light.NoTitleBar"> | 43 | android:theme="@android:style/Theme.Light.NoTitleBar"> |
45 | <intent-filter> | 44 | <intent-filter> |
46 | <category android:name="android.intent.category.DEFAULT"/> | 45 | <category android:name="android.intent.category.DEFAULT"/> |
47 | 46 | ||
48 | <action android:name="android.intent.action.VIEW"/> | 47 | <action android:name="android.intent.action.VIEW"/> |
49 | 48 | ||
50 | <category android:name="android.intent.category.BROWSABLE"/> | 49 | <category android:name="android.intent.category.BROWSABLE"/> |
51 | 50 | ||
52 | <data | 51 | <data |
53 | android:host="com.gump.sdk" | 52 | android:host="com.gump.sdk" |
54 | android:scheme="gump10031"/> | 53 | android:scheme="gump10031"/> |
55 | </intent-filter> | 54 | </intent-filter> |
56 | </activity> | 55 | </activity> |
57 | <activity | ||
58 | android:name="com.gumptech.sdk.ExchangeWindow" | ||
59 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | ||
60 | android:theme="@style/Theme.WinForExchange"> | ||
61 | </activity> | ||
62 | |||
63 | <service android:name="com.gumptech.sdk.PushService"> | ||
64 | </service> | ||
65 | 56 | ||
66 | <!--wechat--> | 57 | <!--wechat--> |
67 | <activity | ||
68 | android:name=".wxapi.WXEntryActivity" | ||
69 | android:exported="true"></activity> | ||
70 | <!-- vk --> | 58 | <!-- vk --> |
71 | <!-- <activity android:name="com.vk.com.gumptech.sdk.VKOpenAuthActivity" /> --> | 59 | <!-- <activity android:name="com.vk.com.gumptech.sdk.VKOpenAuthActivity" /> --> |
72 | <!-- <activity --> | 60 | <!-- <activity --> |
73 | <!-- android:name="com.vk.com.gumptech.sdk.VKServiceActivity" --> | 61 | <!-- android:name="com.vk.com.gumptech.sdk.VKServiceActivity" --> |
74 | <!-- android:label="ServiceActivity" --> | 62 | <!-- android:label="ServiceActivity" --> |
75 | <!-- android:theme="@style/VK.Transparent" /> --> | 63 | <!-- android:theme="@style/VK.Transparent" /> --> |
76 | </application> | 64 | </application> |
77 | 65 | ||
78 | 66 | ||
79 | </manifest> | 67 | </manifest> |
80 | 68 |
GameSDKDemo/src/main/java/com/gumptech/sdk/demo/MainActivity.java
1 | package com.gumptech.sdk.demo; | 1 | package com.gumptech.sdk.demo; |
2 | 2 | ||
3 | import android.app.Activity; | 3 | import android.app.Activity; |
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.util.Log; | 5 | import android.util.Log; |
6 | import android.view.View; | 6 | import android.view.View; |
7 | import android.widget.Button; | 7 | import android.widget.Button; |
8 | import android.widget.TextView; | 8 | import android.widget.TextView; |
9 | import android.widget.Toast; | 9 | import android.widget.Toast; |
10 | 10 | ||
11 | import com.gumptech.sdk.GumpPreference; | 11 | import com.gumptech.sdk.GumpPreference; |
12 | import com.gumptech.sdk.GumpSDK; | 12 | import com.gumptech.sdk.GumpSDK; |
13 | import com.gumptech.sdk.PaymentVersion; | 13 | import com.gumptech.sdk.PaymentVersion; |
14 | import com.gumptech.sdk.SDKSettings; | 14 | import com.gumptech.sdk.SDKSettings; |
15 | import com.gumptech.sdk.bean.GumpUser; | 15 | import com.gumptech.sdk.bean.GumpUser; |
16 | import com.gumptech.sdk.bean.PurchaseResult; | 16 | import com.gumptech.sdk.bean.PurchaseResult; |
17 | import com.gumptech.sdk.callback.InitializeCallback; | 17 | import com.gumptech.sdk.callback.InitializeCallback; |
18 | import com.gumptech.sdk.callback.LoginStateListener; | 18 | import com.gumptech.sdk.callback.LoginStateListener; |
19 | import com.gumptech.sdk.callback.PurchaseCallback; | 19 | import com.gumptech.sdk.callback.PurchaseCallback; |
20 | import com.gumptech.sdk.callback.ResultCallback; | 20 | import com.gumptech.sdk.callback.ResultCallback; |
21 | import com.gumptech.sdk.passport.fb.FBAccessToken; | 21 | import com.gumptech.sdk.passport.fb.FBAccessToken; |
22 | 22 | ||
23 | import java.util.Locale; | 23 | import java.util.Locale; |
24 | 24 | ||
25 | public class MainActivity extends Activity implements PurchaseCallback { | 25 | public class MainActivity extends Activity implements PurchaseCallback { |
26 | 26 | ||
27 | private static final String TAG = "MainActivity"; | 27 | private static final String TAG = "MainActivity"; |
28 | 28 | ||
29 | private TextView tvVersion; | 29 | private TextView tvVersion; |
30 | private TextView userInfo; | 30 | private TextView userInfo; |
31 | 31 | ||
32 | private Button btnLoginOrLogout; | 32 | private Button btnLoginOrLogout; |
33 | private Button btnInit; | ||
33 | 34 | ||
34 | private String appId = "100"; | 35 | private String appId = "100"; |
35 | private String appKey = "f899139df5e1059396431415e770c6dd"; | 36 | private String appKey = "f899139df5e1059396431415e770c6dd"; |
36 | private GumpUser gumpUser; | 37 | private GumpUser gumpUser; |
37 | 38 | ||
38 | 39 | ||
39 | @Override | 40 | @Override |
40 | protected void onCreate(Bundle savedInstanceState) { | 41 | protected void onCreate(Bundle savedInstanceState) { |
41 | super.onCreate(savedInstanceState); | 42 | super.onCreate(savedInstanceState); |
42 | setContentView(R.layout.activity_main); | 43 | setContentView(R.layout.activity_main); |
43 | 44 | ||
44 | tvVersion = findViewById(R.id.version); | 45 | tvVersion = findViewById(R.id.version); |
45 | userInfo = findViewById(R.id.user_info); | 46 | userInfo = findViewById(R.id.user_info); |
46 | btnLoginOrLogout = findViewById(R.id.login_or_logout); | 47 | btnLoginOrLogout = findViewById(R.id.login_or_logout); |
48 | btnInit = findViewById(R.id.init); | ||
47 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { | 49 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { |
48 | 50 | ||
49 | @Override | 51 | @Override |
50 | public void onClick(View v) { | 52 | public void onClick(View v) { |
51 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) | 53 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) |
52 | GumpSDK.start(MainActivity.this); | 54 | GumpSDK.start(MainActivity.this); |
53 | else | 55 | else |
54 | GumpSDK.logout(MainActivity.this); | 56 | GumpSDK.logout(MainActivity.this); |
55 | } | 57 | } |
56 | }); | 58 | }); |
59 | btnInit.setOnClickListener(new View.OnClickListener() { | ||
60 | @Override | ||
61 | public void onClick(View v) { | ||
62 | btnInit.setEnabled(false); | ||
63 | GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { | ||
64 | @Override | ||
65 | public void initComplete(int result) { | ||
66 | if (result == GumpSDK.CODE.OK) { | ||
67 | btnLoginOrLogout.setEnabled(true); | ||
68 | userInfo.setText("initialization has finished"); | ||
69 | } else { | ||
70 | btnInit.setEnabled(true); | ||
71 | userInfo.setText("initialization has error"); | ||
72 | } | ||
73 | } | ||
74 | }); | ||
75 | } | ||
76 | }); | ||
57 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { | 77 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { |
58 | 78 | ||
59 | @Override | 79 | @Override |
60 | public void onClick(View v) { | 80 | public void onClick(View v) { |
61 | Bundle payInfo = new Bundle(); | 81 | Bundle payInfo = new Bundle(); |
62 | payInfo.putString("product", "wa2"); | 82 | payInfo.putString("product", "wa2"); |
63 | payInfo.putFloat("amount", 0.1f); | 83 | payInfo.putFloat("amount", 0.1f); |
64 | payInfo.putString("extraInfo", "This is demo!"); | 84 | payInfo.putString("extraInfo", "This is demo!"); |
65 | payInfo.putString("serverId", "s1"); | 85 | payInfo.putString("serverId", "s1"); |
66 | payInfo.putString("roleId", "100123"); | 86 | payInfo.putString("roleId", "100123"); |
67 | payInfo.putString("sessionKey", gumpUser.getSessionKey().getToken()); | 87 | payInfo.putString("sessionKey", gumpUser.getSessionKey().getToken()); |
68 | GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); | 88 | GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); |
69 | } | 89 | } |
70 | }); | 90 | }); |
71 | findViewById(R.id.iap).setOnClickListener(new View.OnClickListener() { | 91 | findViewById(R.id.iap).setOnClickListener(new View.OnClickListener() { |
72 | @Override | 92 | @Override |
73 | public void onClick(View v) { | 93 | public void onClick(View v) { |
74 | Bundle payInfo = new Bundle(); | 94 | Bundle payInfo = new Bundle(); |
75 | payInfo.putString("product", "180010"); | 95 | payInfo.putString("product", "180010"); |
76 | payInfo.putFloat("amount", 0.1f); | 96 | payInfo.putFloat("amount", 0.1f); |
77 | payInfo.putString("extraInfo", "This is demo!"); | 97 | payInfo.putString("extraInfo", "This is demo!"); |
78 | payInfo.putString("serverId", "100"); | 98 | payInfo.putString("serverId", "100"); |
79 | payInfo.putString("roleId", "100123"); | 99 | payInfo.putString("roleId", "100123"); |
80 | GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this); | 100 | GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this); |
81 | } | 101 | } |
82 | }); | 102 | }); |
83 | 103 | ||
84 | 104 | ||
85 | Log.i("DEMO", "country:" + Locale.getDefault().getCountry() + ",language:" + Locale.getDefault().getLanguage()); | 105 | Log.i("DEMO", "country:" + Locale.getDefault().getCountry() + ",language:" + Locale.getDefault().getLanguage()); |
86 | 106 | ||
87 | GumpSDK.getSettings().setDebug(false); | 107 | GumpSDK.getSettings().setDebug(false); |
88 | /** | 108 | /** |
89 | * 设置是否打印debug日志 | 109 | * 设置是否打印debug日志 |
90 | */ | 110 | */ |
91 | GumpSDK.getSettings().enableDebugLogging(true); | 111 | GumpSDK.getSettings().enableDebugLogging(true); |
92 | /** | 112 | /** |
93 | * 设置启用facebook登录 | 113 | * 设置启用facebook登录 |
94 | */ | 114 | */ |
95 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_FB); | 115 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_FB); |
96 | /** | 116 | /** |
97 | * 设置启用Vk登录 | 117 | * 设置启用Vk登录 |
98 | */ | 118 | */ |
99 | // GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_VK); | 119 | // GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_VK); |
100 | 120 | ||
101 | /** | ||
102 | * 设置启用Wechat登录 | ||
103 | * | ||
104 | */ | ||
105 | // GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_WECHAT); | ||
106 | 121 | ||
107 | /** | 122 | /** |
108 | * 设置启用google登录 | 123 | * 设置启用google登录 |
109 | */ | 124 | */ |
110 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_GOOGLE); | 125 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_GOOGLE); |
111 | 126 | ||
112 | /** | 127 | /** |
113 | * 设置启用Line登录 | 128 | * 设置启用Line登录 |
114 | */ | 129 | */ |
115 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_LINE); | 130 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_LINE); |
116 | /** | 131 | /** |
117 | * 设置屏幕方向 | 132 | * 设置屏幕方向 |
118 | */ | 133 | */ |
119 | GumpSDK.getSettings().setScreenLandscape(true); | 134 | GumpSDK.getSettings().setScreenLandscape(true); |
120 | 135 | ||
121 | /** | 136 | /** |
122 | * 设置支付版本 | 137 | * 设置支付版本 |
123 | */ | 138 | */ |
124 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); | 139 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); |
125 | 140 | ||
126 | /** | 141 | /** |
127 | * 设置用户登录状态监听器 | 142 | * 设置用户登录状态监听器 |
128 | */ | 143 | */ |
129 | 144 | ||
130 | GumpSDK.setUserStateListener(new LoginStateListener() { | 145 | GumpSDK.setUserStateListener(new LoginStateListener() { |
131 | @Override | 146 | @Override |
132 | public void onLoginSuccess(GumpUser user) { | 147 | public void onLoginSuccess(GumpUser user) { |
133 | gumpUser = user; | 148 | gumpUser = user; |
134 | String userType = null; | 149 | String userType = null; |
135 | switch (user.getAccountType()) { | 150 | switch (user.getAccountType()) { |
136 | case GumpPreference.ACCOUNT_TYPE_FB: | 151 | case GumpPreference.ACCOUNT_TYPE_FB: |
137 | userType = "Facebook登录"; | 152 | userType = "Facebook登录"; |
138 | String fbToken = FBAccessToken.getCurrentAccessToken().getToken(); | 153 | String fbToken = FBAccessToken.getCurrentAccessToken().getToken(); |
139 | Log.d(TAG, "FBAccessToken:" + fbToken); | 154 | Log.d(TAG, "FBAccessToken:" + fbToken); |
140 | break; | 155 | break; |
141 | case GumpPreference.ACCOUNT_TYPE_QUICK_REG: | 156 | case GumpPreference.ACCOUNT_TYPE_QUICK_REG: |
142 | userType = "快速登录"; | 157 | userType = "快速登录"; |
143 | break; | 158 | break; |
144 | case GumpPreference.ACCOUNT_TYPE_REG: | 159 | case GumpPreference.ACCOUNT_TYPE_REG: |
145 | userType = "gump注册用户"; | 160 | userType = "gump注册用户"; |
146 | break; | 161 | break; |
147 | case GumpPreference.ACCOUNT_TYPE_VK: | 162 | case GumpPreference.ACCOUNT_TYPE_VK: |
148 | userType = "vk登录"; | 163 | userType = "vk登录"; |
149 | break; | 164 | break; |
150 | case GumpPreference.ACCOUNT_TYPE_GOOGLE: | 165 | case GumpPreference.ACCOUNT_TYPE_GOOGLE: |
151 | userType = "google 登录"; | 166 | userType = "google 登录"; |
152 | break; | 167 | break; |
153 | case GumpPreference.ACCOUNT_TYPE_WECHAT: | ||
154 | userType = "微信登录"; | ||
155 | break; | ||
156 | case GumpPreference.ACCOUNT_TYPE_LINE: | 168 | case GumpPreference.ACCOUNT_TYPE_LINE: |
157 | userType = "Line登录"; | 169 | userType = "Line登录"; |
158 | break; | 170 | break; |
159 | } | 171 | } |
160 | userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType() + ") " + userType + "\n sessionKey:" + user.getSessionKey() | 172 | userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType() + ") " + userType + "\n sessionKey:" + user.getSessionKey() |
161 | .getToken()); | 173 | .getToken()); |
162 | btnLoginOrLogout.setText("Logout"); | 174 | btnLoginOrLogout.setText("Logout"); |
163 | btnLoginOrLogout.setTag(1); | 175 | btnLoginOrLogout.setTag(1); |
164 | } | 176 | } |
165 | 177 | ||
166 | @Override | 178 | @Override |
167 | public void onLoginFailed(int code, String msg) { | 179 | public void onLoginFailed(int code, String msg) { |
168 | userInfo.setText(msg); | 180 | userInfo.setText(msg); |
169 | Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show(); | 181 | Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show(); |
170 | } | 182 | } |
171 | 183 | ||
172 | @Override | 184 | @Override |
173 | public void onLoginCanceled() { | 185 | public void onLoginCanceled() { |
174 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 186 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
175 | } | 187 | } |
176 | 188 | ||
177 | @Override | 189 | @Override |
178 | public void onLogout() { | 190 | public void onLogout() { |
179 | btnLoginOrLogout.setText("Login"); | 191 | btnLoginOrLogout.setText("Login"); |
180 | btnLoginOrLogout.setTag(0); | 192 | btnLoginOrLogout.setTag(0); |
181 | userInfo.setText("User is logout"); | 193 | userInfo.setText("User is logout"); |
182 | } | 194 | } |
183 | 195 | ||
184 | @Override | 196 | @Override |
185 | public void onPermissionDenied(String[] deniedPermissions) { | 197 | public void onPermissionDenied(String[] deniedPermissions) { |
186 | StringBuilder sb = new StringBuilder(); | 198 | StringBuilder sb = new StringBuilder(); |
187 | for (String s : deniedPermissions) { | 199 | for (String s : deniedPermissions) { |
188 | sb.append(s); | 200 | sb.append(s); |
189 | sb.append(","); | 201 | sb.append(","); |
190 | } | 202 | } |
191 | Toast.makeText(MainActivity.this, "Permission denied:" + sb.toString(), Toast.LENGTH_SHORT).show(); | 203 | Toast.makeText(MainActivity.this, "Permission denied:" + sb.toString(), Toast.LENGTH_SHORT).show(); |
192 | } | 204 | } |
193 | }); | 205 | }); |
194 | /** | 206 | /** |
195 | * 初始化sdk | 207 | * 初始化sdk |
196 | */ | 208 | */ |
197 | GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { | 209 | GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { |
198 | @Override | 210 | @Override |
199 | public void initComplete(int result) { | 211 | public void initComplete(int result) { |
200 | if (result == GumpSDK.CODE.OK) { | 212 | if (result == GumpSDK.CODE.OK) { |
201 | btnLoginOrLogout.setEnabled(true); | 213 | btnLoginOrLogout.setEnabled(true); |
202 | 214 | userInfo.setText("initialization has finished"); | |
203 | //checkRisk(); | 215 | //checkRisk(); |
216 | } else { | ||
217 | btnInit.setEnabled(true); | ||
218 | userInfo.setText("initialization has error"); | ||
204 | } | 219 | } |
205 | } | 220 | } |
206 | }); | 221 | }); |
207 | 222 | ||
208 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); | 223 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); |
209 | 224 | ||
210 | } | 225 | } |
211 | 226 | ||
212 | private void checkRisk() { | 227 | private void checkRisk() { |
213 | GumpSDK.checkRisk(this, new ResultCallback() { | 228 | GumpSDK.checkRisk(this, new ResultCallback() { |
214 | @Override | 229 | @Override |
215 | public void onResult(boolean isRisk) { | 230 | public void onResult(boolean isRisk) { |
216 | Log.i(TAG, isRisk ? "There is some risks" : "Nothing is risk"); | 231 | Log.i(TAG, isRisk ? "There is some risks" : "Nothing is risk"); |
217 | } | 232 | } |
218 | }); | 233 | }); |
219 | } | 234 | } |
220 | 235 | ||
221 | @Override | 236 | @Override |
222 | public void onPurchaseCompleted(PurchaseResult result) { | 237 | public void onPurchaseCompleted(PurchaseResult result) { |
223 | Log.i(TAG, "purchase completed"); | 238 | Log.i(TAG, "purchase completed"); |
224 | } | 239 | } |
225 | 240 | ||
226 | @Override | 241 | @Override |
227 | public void onPurchaseError(int code, String msg) { | 242 | public void onPurchaseError(int code, String msg) { |
228 | Log.i(TAG, "purchase error"); | 243 | Log.i(TAG, "purchase error"); |
229 | } | 244 | } |
230 | 245 |
GameSDKDemo/src/main/java/com/gumptech/sdk/demo/wxapi/WXEntryActivity.java
1 | package com.gumptech.sdk.demo.wxapi; | File was deleted | |
2 | |||
3 | import android.os.Bundle; | ||
4 | import android.support.annotation.Nullable; | ||
5 | |||
6 | import com.gumptech.sdk.WXCallbackActivity; | ||
7 | |||
8 | /** | ||
9 | * Created by King on 2018/2/7. | ||
10 | */ | ||
11 | |||
12 | public class WXEntryActivity extends WXCallbackActivity { | ||
13 | |||
14 | @Override | ||
15 | protected void onCreate(@Nullable Bundle bundle) { | ||
16 | super.onCreate(bundle); | ||
17 | } | ||
18 | } | ||
19 | 1 | package com.gumptech.sdk.demo.wxapi; |
GameSDKDemo/src/main/res/layout/activity_main.xml
1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | android:layout_width="match_parent" | 2 | android:layout_width="match_parent" |
3 | android:layout_height="match_parent" | 3 | android:layout_height="match_parent" |
4 | android:background="@android:color/white" | 4 | android:background="@android:color/white" |
5 | android:fitsSystemWindows="true" | 5 | android:fitsSystemWindows="true" |
6 | android:orientation="vertical"> | 6 | android:orientation="vertical"> |
7 | 7 | ||
8 | <TextView | 8 | <TextView |
9 | android:id="@+id/version" | 9 | android:id="@+id/version" |
10 | android:layout_width="wrap_content" | 10 | android:layout_width="wrap_content" |
11 | android:layout_height="wrap_content" | 11 | android:layout_height="wrap_content" |
12 | android:layout_gravity="center_horizontal" | 12 | android:layout_gravity="center_horizontal" |
13 | android:textColor="@color/black_text"/> | 13 | android:textColor="@color/black_text"/> |
14 | 14 | ||
15 | <TextView | 15 | <TextView |
16 | android:id="@+id/user_info" | 16 | android:id="@+id/user_info" |
17 | android:layout_width="match_parent" | 17 | android:layout_width="match_parent" |
18 | android:layout_height="wrap_content" | 18 | android:layout_height="wrap_content" |
19 | android:textColor="@android:color/black"/> | 19 | android:textColor="@android:color/black"/> |
20 | 20 | ||
21 | <Button | 21 | <Button |
22 | android:id="@+id/init" | ||
23 | android:layout_width="match_parent" | ||
24 | android:layout_height="wrap_content" | ||
25 | android:backgroundTint="@color/g_color" | ||
26 | android:enabled="false" | ||
27 | android:text="Initialize"/> | ||
28 | |||
29 | <Button | ||
22 | android:id="@+id/login_or_logout" | 30 | android:id="@+id/login_or_logout" |
23 | android:layout_width="match_parent" | 31 | android:layout_width="match_parent" |
24 | android:layout_height="wrap_content" | 32 | android:layout_height="wrap_content" |
25 | android:backgroundTint="@color/g_color" | 33 | android:backgroundTint="@color/g_color" |
26 | android:enabled="false" | 34 | android:enabled="false" |
27 | android:text="Login"/> | 35 | android:text="Login"/> |
28 | 36 | ||
29 | <Button | 37 | <Button |
30 | android:id="@+id/iap" | 38 | android:id="@+id/iap" |
31 | android:layout_width="match_parent" | 39 | android:layout_width="match_parent" |
32 | android:layout_height="wrap_content" | 40 | android:layout_height="wrap_content" |
33 | android:backgroundTint="@color/g_color" | 41 | android:backgroundTint="@color/g_color" |
34 | android:text="IAP"/> | 42 | android:text="IAP"/> |
35 | 43 | ||
36 | <Button | 44 | <Button |
37 | android:id="@+id/pay" | 45 | android:id="@+id/pay" |
38 | android:layout_width="match_parent" | 46 | android:layout_width="match_parent" |
39 | android:layout_height="wrap_content" | 47 | android:layout_height="wrap_content" |
40 | android:backgroundTint="@color/g_color" | 48 | android:backgroundTint="@color/g_color" |
41 | android:text="pay"/> | 49 | android:text="pay"/> |
42 | 50 | ||
43 | 51 | ||
44 | </LinearLayout> | 52 | </LinearLayout> |
README.md
1 | # Gump SDK 4 for Android接入文档 | 1 | # Gump SDK 4 for Android接入文档 |
2 | 2 | ||
3 | V4.5.6 | 3 | V4.5.8 |
4 | 2018年9月18日 | 4 | 2018年9月20日 |
5 | 5 | ||
6 | ## 版本概述 | 6 | ## 版本概述 |
7 | 7 | ||
8 | 此版本为使用AndroidStudio开发的版本,一改eclipse的工程依赖方式,使用aar的方式提供sdk接入包,除功能外,相对上一版本没有继承关系,请按此文档描述接入. | 8 | 此版本为使用AndroidStudio开发的版本,一改eclipse的工程依赖方式,使用aar的方式提供sdk接入包,除功能外,相对上一版本没有继承关系,请按此文档描述接入. |
9 | 9 | ||
10 | 此SDK适用android4.0以上系统. | 10 | 此SDK适用android4.0以上系统. |
11 | 11 | ||
12 | ## 第一章 接入指南 | 12 | ## 第一章 接入指南 |
13 | ### 1.依赖导入 | 13 | ### 1.依赖导入 |
14 | 配置gradle,以下为必须项 | 14 | 配置gradle,以下为必须项 |
15 | 15 | ||
16 | repositories{ | 16 | repositories{ |
17 | maven{ | 17 | maven{ |
18 | url "http://117.50.8.198:8081/nexus/content/repositories/sdk" | 18 | url "http://117.50.8.198:8081/nexus/content/repositories/sdk" |
19 | } | 19 | } |
20 | } | 20 | } |
21 | dependencies { | 21 | dependencies { |
22 | implementation 'com.gumptech.sdk:GameSDK:4.5.6' | 22 | implementation 'com.gumptech.sdk:GameSDK:4.5.8' |
23 | } | 23 | } |
24 | 24 | ||
25 | 25 | ||
26 | 可选接入vk登录时,需要导入vkLibrary工程,并配置模块依赖,如下 | 26 | 可选接入vk登录时,需要导入vkLibrary工程,并配置模块依赖,如下 |
27 | 27 | ||
28 | implementation 'com.gumptech:VKsdk:1.5.4' | 28 | implementation 'com.gumptech:VKsdk:1.5.4' |
29 | 29 | ||
30 | 选择接入微信登录时,需要增加微信依赖,如下: | 30 | 选择接入微信登录时,需要增加微信依赖,如下: |
31 | 31 | ||
32 | implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.1.4' | 32 | implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.1.4' |
33 | 33 | ||
34 | ### 2.修改AndroidManifest.xml文件 | 34 | ### 2.修改AndroidManifest.xml文件 |
35 | 首先添加必要的权限,如下所示: | 35 | 首先添加必要的权限,如下所示: |
36 | 36 | ||
37 | <uses-permission android:name="android.permission.INTERNET" /> | 37 | <uses-permission android:name="android.permission.INTERNET" /> |
38 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | 38 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> |
39 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | 39 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> |
40 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
41 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> | 40 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> |
42 | <uses-permission android:name="com.android.vending.BILLING" /> | 41 | <uses-permission android:name="com.android.vending.BILLING" /> |
43 | 42 | ||
44 | 其次注册相应的Activity,具体如下: | 43 | 其次注册相应的Activity,具体如下: |
45 | 44 | ||
46 | <activity | 45 | <activity |
47 | android:name="com.gumptech.sdk.ContainerActivity" | 46 | android:name="com.gumptech.sdk.ContainerActivity" |
48 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 47 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
49 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan" | 48 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan" |
50 | android:launchMode="singleTask" | 49 | android:launchMode="singleTask" |
51 | android:theme="@style/Theme.TransparentWin" > | 50 | android:theme="@style/Theme.TransparentWin" > |
52 | </activity> | 51 | </activity> |
53 | <activity | 52 | <activity |
54 | android:name="com.gumptech.sdk.PaymentActivity" | 53 | android:name="com.gumptech.sdk.PaymentActivity" |
55 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 54 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
56 | android:launchMode="singleTask" | 55 | android:launchMode="singleTask" |
57 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > | 56 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > |
58 | <intent-filter> | 57 | <intent-filter> |
59 | <category android:name="android.intent.category.DEFAULT" /> | 58 | <category android:name="android.intent.category.DEFAULT" /> |
60 | <action android:name="android.intent.action.VIEW" /> | 59 | <action android:name="android.intent.action.VIEW" /> |
61 | <category android:name="android.intent.category.BROWSABLE" /> | 60 | <category android:name="android.intent.category.BROWSABLE" /> |
62 | <data | 61 | <data |
63 | android:host="com.gump.sdk" | 62 | android:host="com.gump.sdk" |
64 | android:scheme="gump+游戏的appId" /> | 63 | android:scheme="gump+游戏的appId" /> |
65 | </intent-filter> | 64 | </intent-filter> |
66 | </activity> | 65 | </activity> |
67 | <activity | ||
68 | android:name="com.gumptech.sdk.ExchangeWindow" | ||
69 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | ||
70 | android:theme="@style/Theme.WinForExchange" > | ||
71 | </activity> | ||
72 | |||
73 | <service android:name="com.gumptech.sdk.PushService" /> | ||
74 | 66 | ||
75 | <!-- vk登录使用,若不接入vk,不需配置 --> | 67 | <!-- vk登录使用,若不接入vk,不需配置 --> |
76 | <activity android:name="com.vk.sdk.VKOpenAuthActivity" /> | 68 | <activity android:name="com.vk.sdk.VKOpenAuthActivity" /> |
77 | <activity | 69 | <activity |
78 | android:name="com.vk.sdk.VKServiceActivity" | 70 | android:name="com.vk.sdk.VKServiceActivity" |
79 | android:label="ServiceActivity" | 71 | android:label="ServiceActivity" |
80 | android:theme="@style/VK.Transparent" /> | 72 | android:theme="@style/VK.Transparent" /> |
81 | <!--wechat接入使用,不接入不需要配置--> | ||
82 | <activity | ||
83 | android:name=".wxapi.WXEntryActivity" | ||
84 | android:exported="true"></activity> | ||
85 | 73 | ||
86 | ### 3.向Gump平台索要游戏ID(AppID),完成代码接入 | 74 | ### 3.向Gump平台索要游戏ID(AppID),完成代码接入 |
87 | 正式开始接入逻辑代码前,先介绍下一些附加设置,以方便代码接入 | 75 | 正式开始接入逻辑代码前,先介绍下一些附加设置,以方便代码接入 |
88 | 76 | ||
89 | *是否打印debug日志 | 77 | *是否打印debug日志 |
90 | 78 | ||
91 | GumpSDK.getSettings().enableDebugLogging(true); | 79 | GumpSDK.getSettings().enableDebugLogging(true); |
92 | 80 | ||
93 | *横竖屏控制,默认为横屏,参数为false即为竖屏 | 81 | *横竖屏控制,默认为横屏,参数为false即为竖屏 |
94 | 82 | ||
95 | GumpSDK.getSettings().setScreenLandscape(true); | 83 | GumpSDK.getSettings().setScreenLandscape(true); |
96 | 84 | ||
97 | *设置需要启用的第三方登录,参数可选类型见第二章:[第三方登录平台](http://repository.gumptech.com:81/document/gamesdk4-android/blob/master/IntegrationGuide.md#1-third_plat) 字段说明 | 85 | *设置需要启用的第三方登录,参数可选类型见第二章:[第三方登录平台](http://repository.gumptech.com:81/document/gamesdk4-android/blob/master/IntegrationGuide.md#1-third_plat) 字段说明 |
98 | 86 | ||
99 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_*); | 87 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_*); |
100 | 88 | ||
101 | *若要使用V4版支付请设置 | 89 | *若要使用V4版支付请设置 |
102 | 90 | ||
103 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); | 91 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); |
104 | 92 | ||
105 | #### 1.调用GumpSDK前需要执行初始化。 | 93 | #### 1.调用GumpSDK前需要执行初始化。 |
106 | 94 | ||
107 | 若不需要分渠道 | 95 | 若不需要分渠道 |
108 | 96 | ||
109 | GumpSDK.init(Context,Appid, Appkey,InitializeCallback); | 97 | GumpSDK.init(Context,Appid, Appkey,InitializeCallback); |
110 | 如果需要定义渠道,必须使用如下方法 | 98 | 如果需要定义渠道,必须使用如下方法 |
111 | 99 | ||
112 | GumpSDK.init(Context,Appid, Appkey,ChannelId,InitializeCallback); | 100 | GumpSDK.init(Context,Appid, Appkey,ChannelId,InitializeCallback); |
113 | 101 | ||
114 | InitializeCallback为初始化回调接口,此接口只有一个回调方法initComplete(int result) result标识是否初始化成功,当result等于GumpSDK.CODE.OK时为成功,其他为失败 | 102 | InitializeCallback为初始化回调接口,此接口只有一个回调方法initComplete(int result) result标识是否初始化成功,当result等于GumpSDK.CODE.OK时为成功,其他为失败 |
115 | 103 | ||
116 | #### 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 | 104 | #### 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 |
117 | 105 | ||
118 | GumpSDK.start(Activity); | 106 | GumpSDK.start(Activity); |
119 | 在此之前,开发者需要注册用户状态监听以接受用户的登录/登出通知,通常如下: | 107 | 在此之前,开发者需要注册用户状态监听以接受用户的登录/登出通知,通常如下: |
120 | 108 | ||
121 | GumpSDK.setUserStateListener(new LoginStateListener() { | 109 | GumpSDK.setUserStateListener(new LoginStateListener() { |
122 | @Override | 110 | @Override |
123 | public void onLoginSuccess(GumpUser gumpUser) { | 111 | public void onLoginSuccess(GumpUser gumpUser) { |
124 | //登录成功,用户信息包含在GumpUser对象里 | 112 | //登录成功,用户信息包含在GumpUser对象里 |
125 | } | 113 | } |
126 | 114 | ||
127 | @Override | 115 | @Override |
128 | public void onLoginFailed(int code, String msg) { | 116 | public void onLoginFailed(int code, String msg) { |
129 | //登录出错,根据错误码和信息判断错误类型 | 117 | //登录出错,根据错误码和信息判断错误类型 |
130 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); | 118 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); |
131 | } | 119 | } |
132 | 120 | ||
133 | @Override | 121 | @Override |
134 | public void onLoginCanceled() { | 122 | public void onLoginCanceled() { |
135 | //用户取消登录 | 123 | //用户取消登录 |
136 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 124 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
137 | } | 125 | } |
138 | 126 | ||
139 | @Override | 127 | @Override |
140 | public void onLogout() { | 128 | public void onLogout() { |
141 | //用户登出 | 129 | //用户登出 |
142 | 130 | ||
143 | } | 131 | } |
144 | @Override | 132 | @Override |
145 | public void onPermissionDenied(String[] deniedPermissions) { | 133 | public void onPermissionDenied(String[] deniedPermissions) { |
146 | //用户未授予权限,参数为没有获取的权限 | 134 | //用户未授予权限,参数为没有获取的权限 |
147 | } | 135 | } |
148 | }); | 136 | }); |
149 | 137 | ||
150 | 如上成功登录后收到的GumpUser对象包含以下信息 | 138 | 如上成功登录后收到的GumpUser对象包含以下信息 |
151 | 139 | ||
152 | gumpUser.getUid();//获取用户的userid,此Id标识唯一用户! | 140 | gumpUser.getUid();//获取用户的userid,此Id标识唯一用户! |
153 | gumpUser.getAccountType();//用户类型,此类型数据可从GumpPreference常量获取 | 141 | gumpUser.getAccountType();//用户类型,此类型数据可从GumpPreference常量获取 |
154 | gumpUser.getSessionKey();//登录的sessionKey对象,获取sessionKey字符串请使用此对象的getToken()方法 | 142 | gumpUser.getSessionKey();//登录的sessionKey对象,获取sessionKey字符串请使用此对象的getToken()方法 |
155 | 143 | ||
156 | ***注意:若需要使用微信登录,需要在packageName.wxapi下增加一个名为WXEntryActivity并继承com.gumptech.sdk.WXCallbackActivity的Activity,并参考AndroidManifest.xml设置的说明,做相应的配置,packageName为应用的包名,此Activity不须任何实现。*** | ||
157 | |||
158 | ***以GumpSDKDemo为例,包名为com.gumptech.sdk.demo,则WXEntryActivity的完整包路径为:com.gumptech.sdk.demo.wxapi.WXEntryActivity*** | ||
159 | |||
160 | #### 3.支付功能 | 144 | #### 3.支付功能 |
161 | 1)使用gump通行证登录,其中除nick外所有参数为必传参数 | 145 | 1)使用gump通行证登录,其中除nick外所有参数为必传参数 |
162 | 146 | ||
163 | Bundle payInfo = new Bundle(); | 147 | Bundle payInfo = new Bundle(); |
164 | payInfo.putString("nick", "thi"); | 148 | payInfo.putString("nick", "thi"); |
165 | payInfo.putString("product", "元宝"); | 149 | payInfo.putString("product", "元宝"); |
166 | payInfo.putFloat("amount", 40.0f); | 150 | payInfo.putFloat("amount", 40.0f); |
167 | payInfo.putString("extraInfo", "This is demo!"); | 151 | payInfo.putString("extraInfo", "This is demo!"); |
168 | payInfo.putString("serverId", "B4003"); | 152 | payInfo.putString("serverId", "B4003"); |
169 | payInfo.putString("roleId", "10010"); | 153 | payInfo.putString("roleId", "10010"); |
170 | payInfo.putString("sessionKey","sessionkey"); | 154 | payInfo.putString("sessionKey","sessionkey"); |
171 | GumpSDK.pay(MainActivity.this, payInfo,PurchaseCallback); | 155 | GumpSDK.pay(MainActivity.this, payInfo,PurchaseCallback); |
172 | 调用pay方法时,必须穿入一个bundle对象,包含如上字段,除nick外所有字段必须全部包含,其中sessionKey为登录时返回的sessionKey | 156 | 调用pay方法时,必须穿入一个bundle对象,包含如上字段,除nick外所有字段必须全部包含,其中sessionKey为登录时返回的sessionKey |
173 | 157 | ||
174 | 158 | ||
175 | 2)IAP支付 | 159 | 2)IAP支付 |
176 | 160 | ||
177 | Bundle payInfo = new Bundle(); | 161 | Bundle payInfo = new Bundle(); |
178 | payInfo.putString("product", "gp_skuId"); | 162 | payInfo.putString("product", "gp_skuId"); |
179 | payInfo.putFloat("amount", 0.1f); | 163 | payInfo.putFloat("amount", 0.1f); |
180 | payInfo.putString("extraInfo", "This is demo!"); | 164 | payInfo.putString("extraInfo", "This is demo!"); |
181 | payInfo.putString("serverId", "100"); | 165 | payInfo.putString("serverId", "100"); |
182 | payInfo.putString("roleId","100123"); | 166 | payInfo.putString("roleId","100123"); |
183 | GumpSDK.iap(MainActivity.this, payInfo, PurchaseCallback); | 167 | GumpSDK.iap(MainActivity.this, payInfo, PurchaseCallback); |
184 | 168 | ||
185 | 3)PurchaseCallback为支付状态回调接口,此接口含有3个方法 | 169 | 3)PurchaseCallback为支付状态回调接口,此接口含有3个方法 |
186 | 170 | ||
187 | @Override | 171 | @Override |
188 | public void onPurchaseCompleted(PurchaseResult result) { | 172 | public void onPurchaseCompleted(PurchaseResult result) { |
189 | Log.i(TAG,"purchase completed"); | 173 | Log.i(TAG,"purchase completed"); |
190 | } | 174 | } |
191 | 175 | ||
192 | @Override | 176 | @Override |
193 | public void onPurchaseError(int code, String msg) { | 177 | public void onPurchaseError(int code, String msg) { |
194 | Log.i(TAG,"purchase error"); | 178 | Log.i(TAG,"purchase error"); |
195 | } | 179 | } |
196 | 180 | ||
197 | @Override | 181 | @Override |
198 | public void onPurchaseCanceled() { | 182 | public void onPurchaseCanceled() { |
199 | Log.i(TAG,"purchase canceled"); | 183 | Log.i(TAG,"purchase canceled"); |
200 | } | 184 | } |
201 | 185 | ||
202 | #### 4.注销登录 | 186 | #### 4.注销登录 |
203 | 187 | ||
204 | GumpSDK.logout(Activity); | 188 | GumpSDK.logout(Activity); |
205 | 当此方法调用后,用户退出登录,并会通过LoginStateListener接口通知调用程序!为了便于用户切换登录账户,请在游戏内提供用户注销的触发按钮 | 189 | 当此方法调用后,用户退出登录,并会通过LoginStateListener接口通知调用程序!为了便于用户切换登录账户,请在游戏内提供用户注销的触发按钮 |
206 | #### 5.运营开关接口,若需要接入,会有我方运营人员提出需求,否则不需要接入(若对此接口不知所云,即可认为不需要接入,请自行忽略) | 190 | #### 5.运营开关接口,若需要接入,会有我方运营人员提出需求,否则不需要接入(若对此接口不知所云,即可认为不需要接入,请自行忽略) |
207 | 191 | ||
208 | GumpSDK.checkRisk(this, new ResultCallback() { | 192 | GumpSDK.checkRisk(this, new ResultCallback() { |
209 | @Override | 193 | @Override |
210 | public void onResult(boolean result) { | 194 | public void onResult(boolean result) { |
211 | Log.i(TAG,result?"There is some risks":"Nothing is risk"); | 195 | Log.i(TAG,result?"There is some risks":"Nothing is risk"); |
212 | } | 196 | } |
213 | }); | 197 | }); |
214 | 198 | ||
215 | ## 第二章 常量字段与代码 | 199 | ## 第二章 常量字段与代码 |
216 | ### 1.第三方登录平台(third_plat) | 200 | ### 1.第三方登录平台(third_plat) |
217 | | 常量字段 | 说明 | | 201 | | 常量字段 | 说明 | |
218 | |--------------------------------|--------------| | 202 | |--------------------------------|--------------| |
219 | |SDKSettings.THIRD_SUPPORT_FB | Facebook登录 | | 203 | |SDKSettings.THIRD_SUPPORT_FB | Facebook登录 | |
220 | |SDKSettings.THIRD_SUPPORT_GOOGLE| Google登录 | | 204 | |SDKSettings.THIRD_SUPPORT_GOOGLE| Google登录 | |
221 | |SDKSettings.THIRD_SUPPORT_LINE | Line登录 | | 205 | |SDKSettings.THIRD_SUPPORT_LINE | Line登录 | |
222 | |SDKSettings.THIRD_SUPPORT_VK | VK登录 | | 206 | |SDKSettings.THIRD_SUPPORT_VK | VK登录 | |
223 | |SDKSettings.THIRD_SUPPORT_WECHAT| 微信登录 | | 207 | |
224 | ### 2.登录账户类型 | 208 | ### 2.登录账户类型 |
225 | | 常量字段 | 说明 | | 209 | | 常量字段 | 说明 | |
226 | |-------------------------------------|--------------| | 210 | |-------------------------------------|--------------| |
227 | |GumpPreference.ACCOUNT_TYPE_FB | Facebook用户 | | 211 | |GumpPreference.ACCOUNT_TYPE_FB | Facebook用户 | |
228 | |GumpPreference.ACCOUNT_TYPE_REG | Gump注册用户 | | 212 | |GumpPreference.ACCOUNT_TYPE_REG | Gump注册用户 | |
229 | |GumpPreference.ACCOUNT_TYPE_QUICK_REG| 快速注册用户 | | 213 | |GumpPreference.ACCOUNT_TYPE_QUICK_REG| 快速注册用户 | |
230 | |GumpPreference.ACCOUNT_TYPE_GOOGLE | Google用户 | | 214 | |GumpPreference.ACCOUNT_TYPE_GOOGLE | Google用户 | |
231 | |GumpPreference.ACCOUNT_TYPE_LINE | Line用户 | | 215 | |GumpPreference.ACCOUNT_TYPE_LINE | Line用户 | |
232 | |GumpPreference.ACCOUNT_TYPE_VK | VK用户 | | 216 | |GumpPreference.ACCOUNT_TYPE_VK | VK用户 | |
233 | |GumpPreference.ACCOUNT_TYPE_WECHAT | 微信用户 | | 217 | |
234 | 218 | ||
235 | ## 第三章 常见问题 | 219 | ## 第三章 常见问题 |
236 | ### 问题1: 如何避免混淆对SDK的影响? | 220 | ### 问题1: 如何避免混淆对SDK的影响? |
237 | 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java | 221 | 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java |
238 | 类,导致SDK无法正常工作,解决方法如下: | 222 | 类,导致SDK无法正常工作,解决方法如下: |
239 | Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 | 223 | Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 |
240 | 224 | ||
241 | -keepattributes *Annotation*,InnerClasses,SourceFile,LineNumberTable | 225 | -keepattributes *Annotation*,InnerClasses,SourceFile,LineNumberTable |
242 | -keep public class * extends android.app.Service | 226 | -keep public class * extends android.app.Service |
243 | -keep public class com.google.vending.licensing.ILicensingService | 227 | -keep public class com.google.vending.licensing.ILicensingService |
244 | -keep public class com.android.vending.licensing.ILicensingService | 228 | -keep public class com.android.vending.licensing.ILicensingService |
245 | -keep class com.gumptech.sdk.view.* {*;} | 229 | -keep class com.gumptech.sdk.view.* {*;} |
246 | -keep class com.gumptech.sdk.web.* {*;} | 230 | -keep class com.gumptech.sdk.web.* {*;} |
247 | -keep class com.gumptech.sdk.bridge.impl.*{*;} | 231 | -keep class com.gumptech.sdk.bridge.impl.*{*;} |
248 | 232 | ||
249 | 233 | ||
250 | 使得混淆的时候不会影响SDK的命名空间。 | 234 | 使得混淆的时候不会影响SDK的命名空间。 |