Commit 06e47b8f032b0028fb02eed3dd6ea1c25c508091
0 parents
Exists in
master
修改包名,修改域名,全新打包
Showing 19 changed files with 654 additions and 0 deletions Inline Diff
- GameSDK-release4.1.5.aar
- GameSDKDemo/.gitignore
- GameSDKDemo/build.gradle
- GameSDKDemo/libs/GameSDK-release4.1.5.aar
- GameSDKDemo/proguard-rules.pro
- GameSDKDemo/src/androidTest/java/com/gumptech/sdk/demo/ApplicationTest.java
- GameSDKDemo/src/main/AndroidManifest.xml
- GameSDKDemo/src/main/java/com/gumptech/sdk/demo/MainActivity.java
- GameSDKDemo/src/main/res/drawable-hdpi/ic_launcher.png
- GameSDKDemo/src/main/res/drawable-mdpi/ic_launcher.png
- GameSDKDemo/src/main/res/drawable-xhdpi/ic_launcher.png
- GameSDKDemo/src/main/res/layout/activity_main.xml
- GameSDKDemo/src/main/res/values-w820dp/dimens.xml
- GameSDKDemo/src/main/res/values/colors.xml
- GameSDKDemo/src/main/res/values/dimens.xml
- GameSDKDemo/src/main/res/values/strings.xml
- GameSDKDemo/src/main/res/values/styles.xml
- GameSDKDemo/src/test/java/com/gumptech/sdk/demo/ExampleUnitTest.java
- IntegrationGuide.md
GameSDK-release4.1.5.aar
No preview for this file type
GameSDKDemo/.gitignore
| File was created | 1 | /build | |
| 2 | *.iml |
GameSDKDemo/build.gradle
| File was created | 1 | apply plugin: 'com.android.application' | |
| 2 | |||
| 3 | repositories{ | ||
| 4 | flatDir{ | ||
| 5 | dirs 'libs' | ||
| 6 | } | ||
| 7 | } | ||
| 8 | |||
| 9 | android { | ||
| 10 | compileSdkVersion 22 | ||
| 11 | buildToolsVersion "25.0.0" | ||
| 12 | |||
| 13 | |||
| 14 | defaultConfig { | ||
| 15 | minSdkVersion 9 | ||
| 16 | targetSdkVersion 22 | ||
| 17 | versionCode 2 | ||
| 18 | versionName "1.1" | ||
| 19 | } | ||
| 20 | |||
| 21 | buildTypes { | ||
| 22 | release { | ||
| 23 | minifyEnabled false | ||
| 24 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
| 25 | } | ||
| 26 | } | ||
| 27 | lintOptions{ | ||
| 28 | abortOnError false | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | dependencies { | ||
| 33 | compile fileTree(dir: 'libs', include: ['*.jar']) | ||
| 34 | testCompile 'junit:junit:4.12' | ||
| 35 | compile 'com.android.support:appcompat-v7:22.2.0' | ||
| 36 | compile project(':GameSDK') | ||
| 37 | // compile(name:'GameSDK-release4.1.4',ext:'aar') | ||
| 38 | } | ||
| 39 |
GameSDKDemo/libs/GameSDK-release4.1.5.aar
No preview for this file type
GameSDKDemo/proguard-rules.pro
| File was created | 1 | # Add project specific ProGuard rules here. | |
| 2 | # By default, the flags in this file are appended to flags specified | ||
| 3 | # in D:\DevTools\android-com.gumptech.sdk-windows/tools/proguard/proguard-android.txt | ||
| 4 | # You can edit the include path and order by changing the proguardFiles | ||
| 5 | # directive in build.gradle. | ||
| 6 | # | ||
| 7 | # For more details, see | ||
| 8 | # http://developer.android.com/guide/developing/tools/proguard.html | ||
| 9 | |||
| 10 | # Add any project specific keep options here: | ||
| 11 | |||
| 12 | # If your project uses WebView with JS, uncomment the following | ||
| 13 | # and specify the fully qualified class name to the JavaScript interface | ||
| 14 | # class: | ||
| 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
| 16 | # public *; | ||
| 17 | #} | ||
| 18 |
GameSDKDemo/src/androidTest/java/com/gumptech/sdk/demo/ApplicationTest.java
| File was created | 1 | package com.gumptech.sdk.demo; | |
| 2 | |||
| 3 | import android.app.Application; | ||
| 4 | import android.test.ApplicationTestCase; | ||
| 5 | |||
| 6 | /** | ||
| 7 | * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | ||
| 8 | */ | ||
| 9 | public class ApplicationTest extends ApplicationTestCase<Application> { | ||
| 10 | public ApplicationTest() { | ||
| 11 | super(Application.class); | ||
| 12 | } | ||
| 13 | } |
GameSDKDemo/src/main/AndroidManifest.xml
| File was created | 1 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| 2 | package="com.gumptech.sdk.demo"> | ||
| 3 | |||
| 4 | |||
| 5 | <uses-sdk | ||
| 6 | android:minSdkVersion="9" | ||
| 7 | android:targetSdkVersion="20" /> | ||
| 8 | |||
| 9 | <uses-permission android:name="android.permission.INTERNET" /> | ||
| 10 | <uses-permission android:name="android.permission.BLUETOOTH" /> | ||
| 11 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||
| 12 | <uses-permission android:name="android.permission.WRITE_SETTINGS" /> | ||
| 13 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
| 14 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> | ||
| 15 | <!-- Danger Level permission--> | ||
| 16 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
| 17 | <uses-permission android:name="android.permission.GET_ACCOUNTS" /> | ||
| 18 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | ||
| 19 | <uses-permission android:name="android.permission.SEND_SMS"/> | ||
| 20 | |||
| 21 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> | ||
| 22 | <uses-permission android:name="com.android.vending.BILLING" /> | ||
| 23 | |||
| 24 | <application | ||
| 25 | android:allowBackup="true" | ||
| 26 | android:icon="@drawable/ic_launcher" | ||
| 27 | |||
| 28 | android:label="@string/app_name" > | ||
| 29 | <activity | ||
| 30 | android:name="com.gumptech.sdk.demo.MainActivity" | ||
| 31 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | ||
| 32 | android:label="@string/app_name" | ||
| 33 | android:screenOrientation="portrait" > | ||
| 34 | <intent-filter> | ||
| 35 | <action android:name="android.intent.action.MAIN" /> | ||
| 36 | |||
| 37 | <category android:name="android.intent.category.LAUNCHER" /> | ||
| 38 | </intent-filter> | ||
| 39 | </activity> | ||
| 40 | <activity | ||
| 41 | android:name="com.g.root.ContainerActivity" | ||
| 42 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | ||
| 43 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan" | ||
| 44 | android:launchMode="singleTask" | ||
| 45 | android:theme="@style/Theme.TransparentWin" > | ||
| 46 | </activity> | ||
| 47 | <activity | ||
| 48 | android:name="com.g.root.PaymentActivity" | ||
| 49 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | ||
| 50 | android:launchMode="singleTask" | ||
| 51 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > | ||
| 52 | <intent-filter> | ||
| 53 | <category android:name="android.intent.category.DEFAULT" /> | ||
| 54 | |||
| 55 | <action android:name="android.intent.action.VIEW" /> | ||
| 56 | |||
| 57 | <category android:name="android.intent.category.BROWSABLE" /> | ||
| 58 | |||
| 59 | <data | ||
| 60 | android:host="com.gump.sdk" | ||
| 61 | android:scheme="gump10031" /> | ||
| 62 | </intent-filter> | ||
| 63 | </activity> | ||
| 64 | <activity | ||
| 65 | android:name="com.g.root.ExchangeWindow" | ||
| 66 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | ||
| 67 | android:theme="@style/Theme.WinForExchange" > | ||
| 68 | </activity> | ||
| 69 | |||
| 70 | <service android:name="com.g.root.PushService" > | ||
| 71 | </service> | ||
| 72 | |||
| 73 | <!-- vk --> | ||
| 74 | <!-- <activity android:name="com.vk.com.gumptech.sdk.VKOpenAuthActivity" /> --> | ||
| 75 | <!-- <activity --> | ||
| 76 | <!-- android:name="com.vk.com.gumptech.sdk.VKServiceActivity" --> | ||
| 77 | <!-- android:label="ServiceActivity" --> | ||
| 78 | <!-- android:theme="@style/VK.Transparent" /> --> | ||
| 79 | </application> | ||
| 80 | |||
| 81 | |||
| 82 | </manifest> | ||
| 83 |
GameSDKDemo/src/main/java/com/gumptech/sdk/demo/MainActivity.java
| File was created | 1 | package com.gumptech.sdk.demo; | |
| 2 | |||
| 3 | import android.app.Activity; | ||
| 4 | import android.content.Context; | ||
| 5 | import android.os.Bundle; | ||
| 6 | import android.text.ClipboardManager; | ||
| 7 | import android.util.Log; | ||
| 8 | import android.view.View; | ||
| 9 | import android.widget.Button; | ||
| 10 | import android.widget.TextView; | ||
| 11 | import android.widget.Toast; | ||
| 12 | |||
| 13 | import com.g.root.GumpPreference; | ||
| 14 | import com.g.root.GumpSDK; | ||
| 15 | import com.g.root.PaymentVersion; | ||
| 16 | import com.g.root.bean.GumpUser; | ||
| 17 | import com.g.root.bean.PurchaseResult; | ||
| 18 | import com.g.root.callback.InitializeCallback; | ||
| 19 | import com.g.root.callback.LoginStateListener; | ||
| 20 | import com.g.root.callback.PurchaseCallback; | ||
| 21 | import com.g.root.passport.fb.FBAccessToken; | ||
| 22 | |||
| 23 | public class MainActivity extends Activity implements PurchaseCallback { | ||
| 24 | |||
| 25 | private static final String TAG = "MainActivity"; | ||
| 26 | |||
| 27 | private TextView tvVersion; | ||
| 28 | private TextView userInfo; | ||
| 29 | |||
| 30 | private Button btnLoginOrLogout; | ||
| 31 | |||
| 32 | private String appId = "10022"; | ||
| 33 | private String appKey = "93a27b0bd99bac3e68a440b48aa421ab"; | ||
| 34 | private String sessionKey; | ||
| 35 | |||
| 36 | |||
| 37 | @Override | ||
| 38 | protected void onCreate(Bundle savedInstanceState) { | ||
| 39 | super.onCreate(savedInstanceState); | ||
| 40 | setContentView(R.layout.activity_main); | ||
| 41 | tvVersion = (TextView) findViewById(R.id.version); | ||
| 42 | userInfo = (TextView) findViewById(R.id.user_info); | ||
| 43 | btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); | ||
| 44 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { | ||
| 45 | |||
| 46 | @Override | ||
| 47 | public void onClick(View v) { | ||
| 48 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) | ||
| 49 | GumpSDK.start(MainActivity.this); | ||
| 50 | else | ||
| 51 | GumpSDK.logout(MainActivity.this); | ||
| 52 | } | ||
| 53 | }); | ||
| 54 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { | ||
| 55 | |||
| 56 | @Override | ||
| 57 | public void onClick(View v) { | ||
| 58 | Bundle payInfo = new Bundle(); | ||
| 59 | payInfo.putString("product", "test2"); | ||
| 60 | payInfo.putFloat("amount", 0.1f); | ||
| 61 | payInfo.putString("extraInfo", "This is demo!"); | ||
| 62 | payInfo.putString("serverId", "100"); | ||
| 63 | payInfo.putString("roleId","100123"); | ||
| 64 | payInfo.putString("sessionKey", sessionKey); | ||
| 65 | GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); | ||
| 66 | } | ||
| 67 | }); | ||
| 68 | findViewById(R.id.iap).setOnClickListener(new View.OnClickListener() { | ||
| 69 | @Override | ||
| 70 | public void onClick(View v) { | ||
| 71 | Bundle payInfo = new Bundle(); | ||
| 72 | payInfo.putString("product", "gp_skuId"); | ||
| 73 | payInfo.putFloat("amount", 0.1f); | ||
| 74 | payInfo.putString("extraInfo", "This is demo!"); | ||
| 75 | payInfo.putString("serverId", "100"); | ||
| 76 | payInfo.putString("roleId","100123"); | ||
| 77 | GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this); | ||
| 78 | } | ||
| 79 | }); | ||
| 80 | /** | ||
| 81 | * 设置否是打印debug日志 | ||
| 82 | */ | ||
| 83 | GumpSDK.getSettings().enableDebugLogging(true); | ||
| 84 | /** | ||
| 85 | * 设置是否启用facebook登录 | ||
| 86 | */ | ||
| 87 | GumpSDK.getSettings().setFBEnable(true); | ||
| 88 | /** | ||
| 89 | * 设置是否启用Vk登录 | ||
| 90 | */ | ||
| 91 | GumpSDK.getSettings().setVKEnable(false); | ||
| 92 | /** | ||
| 93 | * 设置屏幕方向 | ||
| 94 | */ | ||
| 95 | GumpSDK.getSettings().setScreenLandscape(true); | ||
| 96 | |||
| 97 | /** | ||
| 98 | * 设置支付版本 | ||
| 99 | */ | ||
| 100 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); | ||
| 101 | |||
| 102 | /** | ||
| 103 | * 设置用户登录状态监听器 | ||
| 104 | */ | ||
| 105 | |||
| 106 | GumpSDK.setUserStateListener(new LoginStateListener() { | ||
| 107 | @Override | ||
| 108 | public void onLoginSuccess(GumpUser user) { | ||
| 109 | ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); | ||
| 110 | cm.setText(user.getSessionKey()); | ||
| 111 | sessionKey = user.getSessionKey(); | ||
| 112 | String userType = null; | ||
| 113 | switch (user.getAccountType()) { | ||
| 114 | case GumpPreference.ACCOUNT_TYPE_FB: | ||
| 115 | userType = "Facebook登录"; | ||
| 116 | String fbToken = FBAccessToken.getCurrentAccessToken().getToken(); | ||
| 117 | Log.d(TAG, "FBAccessToken:" + fbToken); | ||
| 118 | break; | ||
| 119 | case GumpPreference.ACCOUNT_TYPE_QUICK_REG: | ||
| 120 | userType = "快速登录"; | ||
| 121 | break; | ||
| 122 | case GumpPreference.ACCOUNT_TYPE_REG: | ||
| 123 | userType = "gump注册用户"; | ||
| 124 | break; | ||
| 125 | case GumpPreference.ACCOUNT_TYPE_VK: | ||
| 126 | userType = "vk登录"; | ||
| 127 | break; | ||
| 128 | } | ||
| 129 | userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType() + ") " + userType + "\n sessionKey:" + user.getSessionKey()); | ||
| 130 | btnLoginOrLogout.setText("Logout"); | ||
| 131 | btnLoginOrLogout.setTag(1); | ||
| 132 | } | ||
| 133 | |||
| 134 | @Override | ||
| 135 | public void onLoginFailed(int code, String msg) { | ||
| 136 | userInfo.setText(msg); | ||
| 137 | Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show(); | ||
| 138 | } | ||
| 139 | |||
| 140 | @Override | ||
| 141 | public void onLoginCanceled() { | ||
| 142 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | ||
| 143 | } | ||
| 144 | |||
| 145 | @Override | ||
| 146 | public void onLogout() { | ||
| 147 | btnLoginOrLogout.setText("Login"); | ||
| 148 | btnLoginOrLogout.setTag(0); | ||
| 149 | userInfo.setText("User is logout"); | ||
| 150 | } | ||
| 151 | }); | ||
| 152 | /** | ||
| 153 | * 初始化sdk | ||
| 154 | */ | ||
| 155 | GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { | ||
| 156 | @Override | ||
| 157 | public void initComplete(int result) { | ||
| 158 | if (result == GumpSDK.CODE.OK) { | ||
| 159 | btnLoginOrLogout.setEnabled(true); | ||
| 160 | } | ||
| 161 | } | ||
| 162 | }); | ||
| 163 | |||
| 164 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); | ||
| 165 | |||
| 166 | } | ||
| 167 | |||
| 168 | @Override | ||
| 169 | public void onPurchaseCompleted(PurchaseResult result) { | ||
| 170 | Log.i(TAG, "purchase completed"); | ||
| 171 | } | ||
| 172 | |||
| 173 | @Override | ||
| 174 | public void onPurchaseError(int code, String msg) { | ||
| 175 | Log.i(TAG, "purchase error"); | ||
| 176 | } | ||
| 177 | |||
| 178 | @Override | ||
| 179 | public void onPurchaseCanceled() { | ||
| 180 | Log.i(TAG, "purchase canceled"); | ||
| 181 | } | ||
| 182 | |||
| 183 | |||
| 184 | } | ||
| 185 |
GameSDKDemo/src/main/res/drawable-hdpi/ic_launcher.png
7.23 KB
GameSDKDemo/src/main/res/drawable-mdpi/ic_launcher.png
4.73 KB
GameSDKDemo/src/main/res/drawable-xhdpi/ic_launcher.png
9.91 KB
GameSDKDemo/src/main/res/layout/activity_main.xml
| File was created | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 2 | android:layout_width="match_parent" | ||
| 3 | android:layout_height="match_parent" | ||
| 4 | android:background="@android:color/white" | ||
| 5 | android:orientation="vertical"> | ||
| 6 | |||
| 7 | <TextView | ||
| 8 | android:id="@+id/version" | ||
| 9 | android:layout_width="wrap_content" | ||
| 10 | android:layout_height="wrap_content" | ||
| 11 | android:layout_gravity="center_horizontal" | ||
| 12 | android:textColor="@color/black_text" /> | ||
| 13 | |||
| 14 | <TextView | ||
| 15 | android:id="@+id/user_info" | ||
| 16 | android:layout_width="match_parent" | ||
| 17 | android:layout_height="wrap_content" | ||
| 18 | android:textColor="@android:color/black" /> | ||
| 19 | |||
| 20 | <Button | ||
| 21 | android:id="@+id/login_or_logout" | ||
| 22 | android:layout_width="match_parent" | ||
| 23 | android:layout_height="wrap_content" | ||
| 24 | android:backgroundTint="@color/g_color" | ||
| 25 | android:enabled="false" | ||
| 26 | android:text="Login" /> | ||
| 27 | <Button | ||
| 28 | android:id="@+id/iap" | ||
| 29 | android:layout_width="match_parent" | ||
| 30 | android:layout_height="wrap_content" | ||
| 31 | android:backgroundTint="@color/g_color" | ||
| 32 | android:text="IAP"/> | ||
| 33 | |||
| 34 | <Button | ||
| 35 | android:id="@+id/pay" | ||
| 36 | android:layout_width="match_parent" | ||
| 37 | android:layout_height="wrap_content" | ||
| 38 | android:backgroundTint="@color/g_color" | ||
| 39 | android:text="pay" /> | ||
| 40 | |||
| 41 | </LinearLayout> |
GameSDKDemo/src/main/res/values-w820dp/dimens.xml
| File was created | 1 | <resources> | |
| 2 | |||
| 3 | <!-- | ||
| 4 | Example customization of dimensions originally defined in res/values/dimens.xml | ||
| 5 | (such as screen margins) for screens with more than 820dp of available width. This | ||
| 6 | would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). | ||
| 7 | --> | ||
| 8 | <dimen name="activity_horizontal_margin">64dp</dimen> | ||
| 9 | |||
| 10 | </resources> | ||
| 11 |
GameSDKDemo/src/main/res/values/colors.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <resources> | ||
| 3 | <color name="colorPrimary">#3F51B5</color> | ||
| 4 | <color name="colorPrimaryDark">#303F9F</color> | ||
| 5 | <color name="colorAccent">#FF4081</color> | ||
| 6 | <color name="g_color">#55BCDC</color> | ||
| 7 | </resources> | ||
| 8 |
GameSDKDemo/src/main/res/values/dimens.xml
| File was created | 1 | <resources> | |
| 2 | |||
| 3 | <!-- Default screen margins, per the Android Design guidelines. --> | ||
| 4 | <dimen name="activity_horizontal_margin">16dp</dimen> | ||
| 5 | <dimen name="activity_vertical_margin">16dp</dimen> | ||
| 6 | |||
| 7 | </resources> | ||
| 8 |
GameSDKDemo/src/main/res/values/strings.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <resources> | ||
| 3 | |||
| 4 | <string name="app_name">GameSDKSample</string> | ||
| 5 | <string name="hello_world">Hello world!</string> | ||
| 6 | <string name="action_settings">Settings</string> | ||
| 7 | |||
| 8 | </resources> | ||
| 9 |
GameSDKDemo/src/main/res/values/styles.xml
| File was created | 1 | <resources> | |
| 2 | |||
| 3 | <!-- Base application theme. --> | ||
| 4 | <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> | ||
| 5 | <!-- Customize your theme here. --> | ||
| 6 | <item name="colorPrimary">@color/colorPrimary</item> | ||
| 7 | <item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
| 8 | <item name="colorAccent">@color/colorAccent</item> | ||
| 9 | </style> | ||
| 10 | |||
| 11 | </resources> | ||
| 12 |
GameSDKDemo/src/test/java/com/gumptech/sdk/demo/ExampleUnitTest.java
| File was created | 1 | package com.gumptech.sdk.demo; | |
| 2 | |||
| 3 | import org.junit.Test; | ||
| 4 | |||
| 5 | import static org.junit.Assert.*; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. | ||
| 9 | */ | ||
| 10 | public class ExampleUnitTest { | ||
| 11 | @Test | ||
| 12 | public void addition_isCorrect() throws Exception { | ||
| 13 | assertEquals(4, 2 + 2); | ||
| 14 | } | ||
| 15 | } |
IntegrationGuide.md
| File was created | 1 | # Gump SDK 4 for Android接入文档 | |
| 2 | |||
| 3 | V4.1.5 | ||
| 4 | 2017年3月10日 | ||
| 5 | |||
| 6 | ## 版本概述 | ||
| 7 | |||
| 8 | 此版本为使用AndroidStudio开发的第一个版本,一改eclipse的工程依赖方式,使用aar的方式提供sdk接入包,除功能外,相对上一版本没有继承关系,请按此文档描述接入. | ||
| 9 | |||
| 10 | 此SDK适用android2.3以上系统. | ||
| 11 | |||
| 12 | ## 第一章 接入指南 | ||
| 13 | ### 1.依赖导入 | ||
| 14 | 将aar添加到libs目录下,然后配置gradle | ||
| 15 | 以下为必须项 | ||
| 16 | |||
| 17 | repositories{ | ||
| 18 | flatDir{ | ||
| 19 | dirs 'libs' | ||
| 20 | } | ||
| 21 | } | ||
| 22 | dependencies { | ||
| 23 | compile(name:'GameSDK-releaseXXX',ext:'aar') | ||
| 24 | } | ||
| 25 | |||
| 26 | |||
| 27 | 可选接入vk登录时,需要导入vkLibrary工程,并配置模块依赖,如下 | ||
| 28 | |||
| 29 | compile project(':vksdk_library') | ||
| 30 | |||
| 31 | ### 2.修改AndroidManifest.xml文件 | ||
| 32 | 首先添加必要的权限,如下所示: | ||
| 33 | |||
| 34 | <uses-permission android:name="android.permission.INTERNET" /> | ||
| 35 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | ||
| 36 | <uses-permission android:name="android.permission.BLUETOOTH" /> | ||
| 37 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||
| 38 | <uses-permission android:name="android.permission.WRITE_SETTINGS"/> | ||
| 39 | <uses-permission android:name="android.permission.GET_ACCOUNTS"/> | ||
| 40 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | ||
| 41 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
| 42 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> | ||
| 43 | <uses-permission android:name="android.permission.SEND_SMS"/> | ||
| 44 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> | ||
| 45 | <uses-permission android:name="com.android.vending.BILLING" /> | ||
| 46 | |||
| 47 | 其次注册相应的Activity,具体如下: | ||
| 48 | |||
| 49 | <activity | ||
| 50 | android:name="com.g.root.ContainerActivity" | ||
| 51 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | ||
| 52 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan" | ||
| 53 | android:launchMode="singleTask" | ||
| 54 | android:theme="@style/Theme.TransparentWin" > | ||
| 55 | </activity> | ||
| 56 | <activity | ||
| 57 | android:name="com.g.root.PaymentActivity" | ||
| 58 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | ||
| 59 | android:launchMode="singleTask" | ||
| 60 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > | ||
| 61 | <intent-filter> | ||
| 62 | <category android:name="android.intent.category.DEFAULT" /> | ||
| 63 | <action android:name="android.intent.action.VIEW" /> | ||
| 64 | <category android:name="android.intent.category.BROWSABLE" /> | ||
| 65 | <data | ||
| 66 | android:host="com.gump.sdk" | ||
| 67 | android:scheme="gump+游戏的appId" /> | ||
| 68 | </intent-filter> | ||
| 69 | </activity> | ||
| 70 | <activity | ||
| 71 | android:name="com.g.root.ExchangeWindow" | ||
| 72 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | ||
| 73 | android:theme="@style/Theme.WinForExchange" > | ||
| 74 | </activity> | ||
| 75 | |||
| 76 | <service android:name="com.g.root.PushService" /> | ||
| 77 | |||
| 78 | <!-- vk登录使用,若不接入vk,不需配置 --> | ||
| 79 | <activity android:name="com.vk.sdk.VKOpenAuthActivity" /> | ||
| 80 | <activity | ||
| 81 | android:name="com.vk.sdk.VKServiceActivity" | ||
| 82 | android:label="ServiceActivity" | ||
| 83 | android:theme="@style/VK.Transparent" /> | ||
| 84 | |||
| 85 | ### 3.向Gump平台索要游戏ID(AppID),完成代码接入 | ||
| 86 | 正式开始接入逻辑代码前,先介绍下一些附加设置,以方便代码接入 | ||
| 87 | |||
| 88 | *是否打印debug日志 | ||
| 89 | |||
| 90 | GumpSDK.getSettings().enableDebugLogging(true); | ||
| 91 | |||
| 92 | *Gump Logo隐藏 | ||
| 93 | |||
| 94 | GumpSDK.getSettings().setLogoShow(false); | ||
| 95 | |||
| 96 | *横竖屏控制,默认为横屏,参数为false即为竖屏 | ||
| 97 | |||
| 98 | GumpSDK.getSettings().setScreenLandscape(true); | ||
| 99 | |||
| 100 | *设置是否启用Facebook登录和VK登录 | ||
| 101 | |||
| 102 | GumpSDK.getSettings().setFBEnable(true); | ||
| 103 | GumpSDK.getSettings().setVKEnable(true); | ||
| 104 | |||
| 105 | *若要使用V4版支付请设置 | ||
| 106 | |||
| 107 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); | ||
| 108 | |||
| 109 | #### 1.调用GumpSDK前需要执行初始化。 | ||
| 110 | |||
| 111 | 若不需要分渠道 | ||
| 112 | |||
| 113 | GumpSDK.init(Context,Appid, Appkey,InitializeCallback); | ||
| 114 | 如果需要定义渠道,必须使用如下方法 | ||
| 115 | |||
| 116 | GumpSDK.init(Context,Appid, Appkey,ChannelId,InitializeCallback); | ||
| 117 | |||
| 118 | InitializeCallback为初始化回调接口,此接口只有一个回调方法initComplete(int result) result标识是否初始化成功,当result等于GumpSDK.CODE.OK时为成功,其他为失败 | ||
| 119 | |||
| 120 | #### 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 | ||
| 121 | |||
| 122 | GumpSDK.start(Activity); | ||
| 123 | 在此之前,开发者需要注册用户状态监听以接受用户的登录/登出通知,通常如下: | ||
| 124 | |||
| 125 | GumpSDK.setUserStateListener(new LoginStateListener() { | ||
| 126 | @Override | ||
| 127 | public void onLoginSuccess(GumpUser gumpUser) { | ||
| 128 | //登录成功,用户信息包含在GumpUser对象里 | ||
| 129 | } | ||
| 130 | |||
| 131 | @Override | ||
| 132 | public void onLoginFailed(int code, String msg) { | ||
| 133 | //登录出错,根据错误码和信息判断错误类型 | ||
| 134 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); | ||
| 135 | } | ||
| 136 | |||
| 137 | @Override | ||
| 138 | public void onLoginCanceled() { | ||
| 139 | //用户取消登录 | ||
| 140 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | ||
| 141 | } | ||
| 142 | |||
| 143 | @Override | ||
| 144 | public void onLogout() { | ||
| 145 | //用户登出 | ||
| 146 | |||
| 147 | } | ||
| 148 | }); | ||
| 149 | |||
| 150 | 如上成功登录后收到的GumpUser对象包含以下信息 | ||
| 151 | |||
| 152 | gumpUser.getUid();//获取用户的userid,此Id标识唯一用户! | ||
| 153 | gumpUser.getAccountType();//用户类型,此类型数据可从GumpPreference常量获取 | ||
| 154 | gumpUser.getSessionKey();//登录的sesionKey | ||
| 155 | |||
| 156 | |||
| 157 | #### 3.支付功能 | ||
| 158 | 1)使用gump通行证登录,其中除nick和roleId外所有参数为必传参数 | ||
| 159 | |||
| 160 | Bundle payInfo = new Bundle(); | ||
| 161 | payInfo.putString("nick", "thi"); | ||
| 162 | payInfo.putString("product", "元宝"); | ||
| 163 | payInfo.putFloat("amount", 40.0f); | ||
| 164 | payInfo.putString("extraInfo", "This is demo!"); | ||
| 165 | payInfo.putString("serverId", "B4003"); | ||
| 166 | payInfo.putString("roleId", "10010"); | ||
| 167 | payInfo.putString("sessionKey","sessionkey"); | ||
| 168 | GumpSDK.pay(MainActivity.this, payInfo,PurchaseCallback); | ||
| 169 | 调用pay方法时,必须穿入一个bundle对象,包含如上字段,除nick和roleId外所有字段必须全部包含,其中sessionKey为登录时返回的sessionKey | ||
| 170 | |||
| 171 | |||
| 172 | 2)IAP支付,roleId为可选参数,其他参数必传 | ||
| 173 | |||
| 174 | Bundle payInfo = new Bundle(); | ||
| 175 | payInfo.putString("product", "gp_skuId"); | ||
| 176 | payInfo.putFloat("amount", 0.1f); | ||
| 177 | payInfo.putString("extraInfo", "This is demo!"); | ||
| 178 | payInfo.putString("serverId", "100"); | ||
| 179 | payInfo.putString("roleId","100123"); | ||
| 180 | GumpSDK.iap(MainActivity.this, payInfo, PurchaseCallback); | ||
| 181 | |||
| 182 | 3)PurchaseCallback为支付状态回调接口,此接口含有3个方法 | ||
| 183 | |||
| 184 | @Override | ||
| 185 | public void onPurchaseCompleted(PurchaseResult result) { | ||
| 186 | Log.i(TAG,"purchase completed"); | ||
| 187 | } | ||
| 188 | |||
| 189 | @Override | ||
| 190 | public void onPurchaseError(int code, String msg) { | ||
| 191 | Log.i(TAG,"purchase error"); | ||
| 192 | } | ||
| 193 | |||
| 194 | @Override | ||
| 195 | public void onPurchaseCanceled() { | ||
| 196 | Log.i(TAG,"purchase canceled"); | ||
| 197 | } | ||
| 198 | |||
| 199 | #### 4.注销登录 | ||
| 200 | |||
| 201 | GumpSDK.logout(Activity); | ||
| 202 | 当此方法调用后,用户退出登录,并会通过LoginStateListener接口通知调用程序!为了便于用户切换登录账户,请在游戏内提供用户注销的触发按钮 | ||
| 203 | ## 第二章 常见问题 | ||
| 204 | ### 问题1: 如何避免混淆对SDK的影响? | ||
| 205 | 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java | ||
| 206 | 类,导致SDK无法正常工作,解决方法如下: | ||
| 207 | Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 | ||
| 208 | |||
| 209 | -keepattributes *Annotation*,InnerClasses,SourceFile,LineNumberTable | ||
| 210 | -keep public class * extends android.app.Service | ||
| 211 | -keep public class com.google.vending.licensing.ILicensingService | ||
| 212 | -keep public class com.android.vending.licensing.ILicensingService | ||
| 213 | -keep class com.g.root.view.* {*;} | ||
| 214 | -keep class com.g.root.web.* {*;} | ||
| 215 | -keep class com.g.root.bridge.impl.*{*;} | ||
| 216 | |||
| 217 | |||
| 218 | 使得混淆的时候不会影响SDK的命名空间。 |