Commit 2a5af05fae54d083d56df35b01f8a491a4cb95f9
1 parent
1b1227b3bf
Exists in
master
release 1.0.3
修改横竖屏切换崩溃或重复加载问题 增加支付宝页面支付配置,支持无支付宝客户端时使用页面支付 增加微信支付的条件判断,无微信不显示微信支付 增加activity configChanges配置,过滤屏幕改变引起的重加载 修改cn域名
Showing 7 changed files with 55 additions and 28 deletions Inline Diff
- InlandSDKDemo/AndroidManifest.xml
- InlandSDKDemo/src/com/gump/inland/sdk/demo/MainActivity.java
- InlandSDKRelease/libs/InlandSDK_v1.0.1_proguard.jar
- InlandSDKRelease/libs/InlandSDK_v1.0.3_proguard.jar
- InlandSDKRelease/res/layout/fragment_sign_choice.xml
- InlandSDKRelease/res/values/strings.xml
- IntegrationGuide.md
InlandSDKDemo/AndroidManifest.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
3 | package="com.ninjaonline" | 3 | package="com.ninjaonline" |
4 | android:versionCode="1" | 4 | android:versionCode="1" |
5 | android:versionName="1.0" > | 5 | android:versionName="1.0" > |
6 | 6 | ||
7 | <uses-sdk | 7 | <uses-sdk |
8 | android:minSdkVersion="10" | 8 | android:minSdkVersion="10" |
9 | android:targetSdkVersion="21" /> | 9 | android:targetSdkVersion="21" /> |
10 | 10 | ||
11 | <uses-permission android:name="android.permission.INTERNET" /> | 11 | <uses-permission android:name="android.permission.INTERNET" /> |
12 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | 12 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
13 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | 13 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> |
14 | <uses-permission android:name="android.permission.BLUETOOTH" /> | 14 | <uses-permission android:name="android.permission.BLUETOOTH" /> |
15 | <uses-permission android:name="android.permission.GET_ACCOUNTS" /> | 15 | <uses-permission android:name="android.permission.GET_ACCOUNTS" /> |
16 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | 16 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
17 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | 17 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
18 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> | 18 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> |
19 | <uses-permission android:name="android.permission.WRITE_SETTINGS" /> | 19 | <uses-permission android:name="android.permission.WRITE_SETTINGS" /> |
20 | <!-- 以下是银联支付专用 --> | 20 | <!-- 以下是银联支付专用 --> |
21 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> | 21 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> |
22 | 22 | ||
23 | 23 | ||
24 | <application | 24 | <application |
25 | android:allowBackup="true" | 25 | android:allowBackup="true" |
26 | android:icon="@drawable/ic_launcher" | 26 | android:icon="@drawable/ic_launcher" |
27 | android:label="@string/app_name" > | 27 | android:label="@string/app_name" > |
28 | <activity | 28 | <activity |
29 | android:name="com.gump.inland.sdk.demo.MainActivity" | 29 | android:name="com.gump.inland.sdk.demo.MainActivity" |
30 | android:screenOrientation="landscape" | ||
31 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | ||
30 | android:label="@string/app_name" > | 32 | android:label="@string/app_name" > |
31 | <intent-filter> | 33 | <intent-filter> |
32 | <action android:name="android.intent.action.MAIN" /> | 34 | <action android:name="android.intent.action.MAIN" /> |
33 | |||
34 | <category android:name="android.intent.category.LAUNCHER" /> | 35 | <category android:name="android.intent.category.LAUNCHER" /> |
35 | </intent-filter> | 36 | </intent-filter> |
36 | <intent-filter> | 37 | <intent-filter> |
37 | <action android:name="android.intent.action.VIEW" /> | 38 | <action android:name="android.intent.action.VIEW" /> |
38 | 39 | ||
39 | <category android:name="android.intent.category.DEFAULT" /> | 40 | <category android:name="android.intent.category.DEFAULT" /> |
40 | 41 | ||
41 | <data android:scheme="wxdb562d299ac311e0" /> | 42 | <data android:scheme="wxdb562d299ac311e0" /> |
42 | </intent-filter> | 43 | </intent-filter> |
43 | </activity> | 44 | </activity> |
44 | <activity | 45 | <activity |
45 | android:name="com.gump.inland.gamesdk.PassportBaseActivity" | 46 | android:name="com.gump.inland.gamesdk.PassportBaseActivity" |
47 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | ||
46 | android:theme="@style/Theme.TransparentWin" > | 48 | android:theme="@style/Theme.TransparentWin" > |
47 | </activity> | 49 | </activity> |
48 | <!-- wx callback --> | 50 | <!-- wx callback --> |
49 | <activity | 51 | <activity |
50 | android:name="com.ninjaonline.wxapi.WXPayEntryActivity" | 52 | android:name="com.ninjaonline.wxapi.WXPayEntryActivity" |
51 | android:exported="true" > | 53 | android:exported="true" > |
52 | </activity> | 54 | </activity> |
53 | <!-- unionPay --> | 55 | <!-- unionPay --> |
54 | <activity | 56 | <activity |
55 | android:name="com.unionpay.uppay.PayActivity" | 57 | android:name="com.unionpay.uppay.PayActivity" |
56 | android:configChanges="orientation|keyboardHidden" | 58 | android:configChanges="orientation|keyboardHidden" |
57 | android:excludeFromRecents="true" | 59 | android:excludeFromRecents="true" |
58 | android:label="@string/app_name" | 60 | android:label="@string/app_name" |
59 | android:screenOrientation="portrait" | 61 | android:screenOrientation="portrait" |
60 | android:windowSoftInputMode="adjustResize" /> | 62 | android:windowSoftInputMode="adjustResize" /> |
63 | <!-- alipay sdk begin --> | ||
64 | <activity | ||
65 | android:name="com.alipay.sdk.app.H5PayActivity" | ||
66 | android:configChanges="orientation|keyboardHidden|navigation" | ||
67 | android:exported="false" | ||
68 | android:screenOrientation="behind" | ||
69 | android:windowSoftInputMode="adjustResize|stateHidden" > | ||
70 | </activity> | ||
71 | |||
72 | <!-- alipay sdk end --> | ||
61 | </application> | 73 | </application> |
62 | 74 |
InlandSDKDemo/src/com/gump/inland/sdk/demo/MainActivity.java
1 | package com.gump.inland.sdk.demo; | 1 | package com.gump.inland.sdk.demo; |
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 | 10 | ||
11 | import com.gump.inland.gamesdk.InlandSDK; | 11 | import com.gump.inland.gamesdk.InlandSDK; |
12 | import com.gump.inland.gamesdk.InlandSDKCallback; | 12 | import com.gump.inland.gamesdk.InlandSDKCallback; |
13 | import com.gump.inland.gamesdk.InlandSDKException; | 13 | import com.gump.inland.gamesdk.InlandSDKException; |
14 | import com.gump.inland.gamesdk.bean.GumpUser; | 14 | import com.gump.inland.gamesdk.bean.GumpUser; |
15 | import com.gump.inland.gamesdk.bean.PayRequest; | 15 | import com.gump.inland.gamesdk.bean.PayRequest; |
16 | import com.gump.inland.gamesdk.callback.PurchaseCallback; | 16 | import com.gump.inland.gamesdk.callback.PurchaseCallback; |
17 | import com.gump.inland.gamesdk.passport.Passport; | 17 | import com.gump.inland.gamesdk.passport.Passport; |
18 | import com.ninjaonline.R; | 18 | import com.ninjaonline.R; |
19 | 19 | ||
20 | public class MainActivity extends Activity { | 20 | public class MainActivity extends Activity { |
21 | 21 | ||
22 | private static final String TAG = "MainActivity"; | 22 | private static final String TAG = "MainActivity"; |
23 | private TextView tvSDKInfo; | 23 | private TextView tvSDKInfo; |
24 | private TextView tvUserInfo; | 24 | private TextView tvUserInfo; |
25 | private TextView tvPurchaseResult; | 25 | private TextView tvPurchaseResult; |
26 | private Button btnLogin; | 26 | private Button btnLogin; |
27 | private Button btnPay; | 27 | private Button btnPay; |
28 | 28 | ||
29 | @Override | 29 | @Override |
30 | protected void onCreate(Bundle savedInstanceState) { | 30 | protected void onCreate(Bundle savedInstanceState) { |
31 | super.onCreate(savedInstanceState); | 31 | super.onCreate(savedInstanceState); |
32 | setContentView(R.layout.activity_main); | 32 | setContentView(R.layout.activity_main); |
33 | tvSDKInfo = (TextView) findViewById(R.id.sdk_info); | 33 | tvSDKInfo = (TextView) findViewById(R.id.sdk_info); |
34 | tvUserInfo = (TextView) findViewById(R.id.user_info); | 34 | tvUserInfo = (TextView) findViewById(R.id.user_info); |
35 | tvPurchaseResult = (TextView) findViewById(R.id.purchase_result); | 35 | tvPurchaseResult = (TextView) findViewById(R.id.purchase_result); |
36 | btnLogin = (Button) findViewById(R.id.login); | 36 | btnLogin = (Button) findViewById(R.id.login); |
37 | btnPay = (Button) findViewById(R.id.purchase); | 37 | btnPay = (Button) findViewById(R.id.purchase); |
38 | 38 | ||
39 | Log.d(TAG, "MainActivity onCreate"); | 39 | Log.d(TAG, "MainActivity onCreate"); |
40 | InlandSDK.setIsDebugEnable(false); | 40 | InlandSDK.setIsDebugEnable(false); |
41 | InlandSDK.setScreenLandscape(false); | 41 | InlandSDK.setScreenLandscape(true); |
42 | InlandSDK.initializeSDK("10000", "dkfjgljdlgjldjgl","1001"); | 42 | InlandSDK.initializeSDK("10000", "dkfjgljdlgjldjgl"); |
43 | Passport.getInstance().registerCallback(new InlandSDKCallback<GumpUser>() { | 43 | Passport.getInstance().registerCallback(new InlandSDKCallback<GumpUser>() { |
44 | 44 | ||
45 | @Override | 45 | @Override |
46 | public void onSuccess(GumpUser result) { | 46 | public void onSuccess(GumpUser result) { |
47 | Log.d(TAG, "gumpUser:" + result.toString()); | 47 | Log.d(TAG, "gumpUser:" + result.toString()); |
48 | btnLogin.setVisibility(View.GONE); | 48 | btnLogin.setVisibility(View.GONE); |
49 | tvUserInfo.setText(formatUserInfo(result)); | 49 | tvUserInfo.setText(formatUserInfo(result)); |
50 | btnPay.setVisibility(View.VISIBLE); | 50 | btnPay.setVisibility(View.VISIBLE); |
51 | } | 51 | } |
52 | 52 | ||
53 | @Override | 53 | @Override |
54 | public void onError(InlandSDKException error) { | 54 | public void onError(InlandSDKException error) { |
55 | Log.d(TAG, "login error:" + error.getMessage()); | 55 | Log.d(TAG, "login error:" + error.getMessage()); |
56 | } | 56 | } |
57 | 57 | ||
58 | @Override | 58 | @Override |
59 | public void onCancel() { | 59 | public void onCancel() { |
60 | Log.d(TAG, "login be canceled"); | 60 | Log.d(TAG, "login be canceled"); |
61 | } | 61 | } |
62 | }); | 62 | }); |
63 | 63 | ||
64 | tvSDKInfo.setText(getSDKInfo()); | 64 | tvSDKInfo.setText(getSDKInfo()); |
65 | btnLogin.setOnClickListener(new View.OnClickListener() { | 65 | btnLogin.setOnClickListener(new View.OnClickListener() { |
66 | 66 | ||
67 | @Override | 67 | @Override |
68 | public void onClick(View v) { | 68 | public void onClick(View v) { |
69 | Passport.getInstance().login(MainActivity.this); | 69 | Passport.getInstance().login(MainActivity.this); |
70 | } | 70 | } |
71 | }); | 71 | }); |
72 | btnPay.setOnClickListener(new View.OnClickListener() { | 72 | btnPay.setOnClickListener(new View.OnClickListener() { |
73 | 73 | ||
74 | @Override | 74 | @Override |
75 | public void onClick(View v) { | 75 | public void onClick(View v) { |
76 | PayRequest payRequest = new PayRequest(); | 76 | PayRequest payRequest = new PayRequest(); |
77 | payRequest.setPrice(1); | 77 | payRequest.setPrice(1); |
78 | payRequest.setProduct("玄冥剑"); | 78 | payRequest.setProduct("玄冥剑"); |
79 | payRequest.setExtOrder("p100201508311731"); | 79 | payRequest.setExtOrder("p100201508311731"); |
80 | payRequest.setGumpUid(Passport.getInstance().getGumpUser().getUid()); | 80 | payRequest.setGumpUid(Passport.getInstance().getGumpUser().getUid()); |
81 | InlandSDK.purchase(MainActivity.this, payRequest, new PurchaseCallback() { | 81 | InlandSDK.purchase(MainActivity.this, payRequest, new PurchaseCallback() { |
82 | 82 | ||
83 | @Override | 83 | @Override |
84 | public void onPurchaseError(Exception e) { | 84 | public void onPurchaseError(Exception e) { |
85 | Log.w(TAG, "purchase error:" + e.getMessage()); | 85 | Log.w(TAG, "purchase error:" + e.getMessage()); |
86 | tvPurchaseResult.setText("purchase occured an error:" + e.getMessage()); | 86 | tvPurchaseResult.setText("purchase occured an error:" + e.getMessage()); |
87 | } | 87 | } |
88 | 88 | ||
89 | @Override | 89 | @Override |
90 | public void onPurchaseSuccess(String gumpTransId, String extOrder) { | 90 | public void onPurchaseSuccess(String gumpTransId, String extOrder) { |
91 | Log.d(TAG, "purchase success:" + gumpTransId + ",extorder:" + extOrder); | 91 | Log.d(TAG, "purchase success:" + gumpTransId + ",extorder:" + extOrder); |
92 | tvPurchaseResult.setText("purchase " + gumpTransId + " success,extorder:" + extOrder); | 92 | tvPurchaseResult.setText("purchase " + gumpTransId + " success,extorder:" + extOrder); |
93 | } | 93 | } |
94 | 94 | ||
95 | @Override | 95 | @Override |
96 | public void onPurchaseCanceled() { | 96 | public void onPurchaseCanceled() { |
97 | Log.d(TAG, "purchase be canceled"); | 97 | Log.d(TAG, "purchase be canceled"); |
98 | tvPurchaseResult.setText("purchase be canceled"); | 98 | tvPurchaseResult.setText("purchase be canceled"); |
99 | } | 99 | } |
100 | }); | 100 | }); |
101 | } | 101 | } |
102 | }); | 102 | }); |
103 | } | 103 | } |
104 | 104 | ||
105 | @Override | 105 | @Override |
106 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | 106 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
107 | if (!InlandSDK.onActivityResult(requestCode, resultCode, data)) | 107 | if (!InlandSDK.onActivityResult(requestCode, resultCode, data)) |
108 | super.onActivityResult(requestCode, resultCode, data); | 108 | super.onActivityResult(requestCode, resultCode, data); |
109 | } | 109 | } |
110 | 110 | ||
111 | private String getSDKInfo() { | 111 | private String getSDKInfo() { |
112 | StringBuilder str = new StringBuilder(); | 112 | StringBuilder str = new StringBuilder(); |
113 | str.append("SDK version:"); | 113 | str.append("SDK version:"); |
114 | str.append(InlandSDK.getVersion()); | 114 | str.append(InlandSDK.getVersion()); |
115 | str.append("\nappId:"); | 115 | str.append("\nappId:"); |
116 | str.append(InlandSDK.getAppId()); | 116 | str.append(InlandSDK.getAppId()); |
117 | str.append("\nappKey:"); | 117 | str.append("\nappKey:"); |
118 | str.append(InlandSDK.getAppKey()); | 118 | str.append(InlandSDK.getAppKey()); |
119 | return str.toString(); | 119 | return str.toString(); |
120 | } | 120 | } |
121 | 121 | ||
122 | private String formatUserInfo(GumpUser user) { | 122 | private String formatUserInfo(GumpUser user) { |
123 | StringBuilder str = new StringBuilder(); | 123 | StringBuilder str = new StringBuilder(); |
124 | str.append("Logined User information:\n"); | 124 | str.append("Logined User information:\n"); |
125 | str.append("userId:" + user.getUid()); | 125 | str.append("userId:" + user.getUid()); |
126 | str.append("\nacccountType:" + user.getAccountType()); | 126 | str.append("\nacccountType:" + user.getAccountType()); |
127 | str.append("\nsessionKey:" + user.getSessionKey()); | 127 | str.append("\nsessionKey:" + user.getSessionKey()); |
128 | return str.toString(); | 128 | return str.toString(); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 |
InlandSDKRelease/libs/InlandSDK_v1.0.1_proguard.jar
No preview for this file type
InlandSDKRelease/libs/InlandSDK_v1.0.3_proguard.jar
No preview for this file type
InlandSDKRelease/res/layout/fragment_sign_choice.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
4 | android:layout_height="wrap_content" | 4 | android:layout_height="wrap_content" |
5 | android:gravity="center" | 5 | android:gravity="center" |
6 | android:orientation="vertical" > | 6 | android:orientation="vertical" > |
7 | 7 | ||
8 | <LinearLayout | 8 | <LinearLayout |
9 | android:layout_width="match_parent" | 9 | android:layout_width="match_parent" |
10 | android:layout_height="wrap_content" | 10 | android:layout_height="wrap_content" |
11 | android:background="@color/white_translucent" | 11 | android:background="@color/white_translucent" |
12 | android:orientation="vertical" > | 12 | android:orientation="vertical" > |
13 | 13 | ||
14 | <LinearLayout | 14 | <LinearLayout |
15 | android:layout_width="match_parent" | 15 | android:layout_width="match_parent" |
16 | android:layout_height="31dp" | 16 | android:layout_height="31dp" |
17 | android:layout_marginLeft="35dp" | 17 | android:layout_marginLeft="35dp" |
18 | android:layout_marginRight="35dp" | 18 | android:layout_marginRight="35dp" |
19 | android:layout_marginTop="13dp" | 19 | android:layout_marginTop="13dp" |
20 | android:background="@color/white" > | 20 | android:background="@color/white" > |
21 | 21 | ||
22 | <ImageView | 22 | <ImageView |
23 | android:layout_width="wrap_content" | 23 | android:layout_width="wrap_content" |
24 | android:layout_height="wrap_content" | 24 | android:layout_height="wrap_content" |
25 | android:layout_gravity="center_vertical" | 25 | android:layout_gravity="center_vertical" |
26 | android:layout_marginLeft="9.5dp" | 26 | android:layout_marginLeft="9.5dp" |
27 | android:layout_marginRight="9.5dp" | 27 | android:layout_marginRight="9.5dp" |
28 | android:src="@drawable/ic_user" /> | 28 | android:src="@drawable/ic_user" /> |
29 | 29 | ||
30 | <View | 30 | <View |
31 | android:layout_width="1dp" | 31 | android:layout_width="1dp" |
32 | android:layout_height="20dp" | 32 | android:layout_height="20dp" |
33 | android:layout_gravity="center_vertical" | 33 | android:layout_gravity="center_vertical" |
34 | android:background="@color/light_gray" /> | 34 | android:background="@color/light_gray" /> |
35 | 35 | ||
36 | <EditText | 36 | <EditText |
37 | android:id="@+id/username" | 37 | android:id="@+id/username" |
38 | android:layout_width="match_parent" | 38 | android:layout_width="match_parent" |
39 | android:layout_height="match_parent" | 39 | android:layout_height="match_parent" |
40 | android:background="@color/transparent" | 40 | android:background="@color/transparent" |
41 | android:hint="@string/user_name_hint" | 41 | android:hint="@string/user_name_hint" |
42 | android:paddingLeft="6dp" /> | 42 | android:paddingLeft="6dp" /> |
43 | </LinearLayout> | 43 | </LinearLayout> |
44 | 44 | ||
45 | <LinearLayout | 45 | <LinearLayout |
46 | android:layout_width="match_parent" | 46 | android:layout_width="match_parent" |
47 | android:layout_height="31dp" | 47 | android:layout_height="31dp" |
48 | android:layout_marginLeft="35dp" | 48 | android:layout_marginLeft="35dp" |
49 | android:layout_marginRight="35dp" | 49 | android:layout_marginRight="35dp" |
50 | android:layout_marginTop="16dp" | 50 | android:layout_marginTop="16dp" |
51 | android:background="@color/white" | 51 | android:background="@color/white" |
52 | android:orientation="horizontal" > | 52 | android:orientation="horizontal" > |
53 | 53 | ||
54 | <ImageView | 54 | <ImageView |
55 | android:layout_width="wrap_content" | 55 | android:layout_width="wrap_content" |
56 | android:layout_height="wrap_content" | 56 | android:layout_height="wrap_content" |
57 | android:layout_gravity="center_vertical" | 57 | android:layout_gravity="center_vertical" |
58 | android:layout_marginLeft="12.5dp" | 58 | android:layout_marginLeft="12.5dp" |
59 | android:layout_marginRight="12.5dp" | 59 | android:layout_marginRight="12.5dp" |
60 | android:src="@drawable/ic_pwd" /> | 60 | android:src="@drawable/ic_pwd" /> |
61 | 61 | ||
62 | <View | 62 | <View |
63 | android:layout_width="1dp" | 63 | android:layout_width="1dp" |
64 | android:layout_height="20dp" | 64 | android:layout_height="20dp" |
65 | android:layout_gravity="center_vertical" | 65 | android:layout_gravity="center_vertical" |
66 | android:background="@color/light_gray" /> | 66 | android:background="@color/light_gray" /> |
67 | 67 | ||
68 | <EditText | 68 | <EditText |
69 | android:id="@+id/pwd" | 69 | android:id="@+id/pwd" |
70 | android:layout_width="match_parent" | 70 | android:layout_width="match_parent" |
71 | android:layout_height="match_parent" | 71 | android:layout_height="match_parent" |
72 | android:background="@color/white" | 72 | android:background="@color/white" |
73 | android:hint="@string/password_hint" | 73 | android:hint="@string/password_hint" |
74 | android:inputType="textPassword" | 74 | android:inputType="textPassword" |
75 | android:paddingLeft="6dp" /> | 75 | android:paddingLeft="6dp" /> |
76 | </LinearLayout> | 76 | </LinearLayout> |
77 | 77 | ||
78 | <LinearLayout | 78 | <LinearLayout |
79 | android:layout_width="fill_parent" | 79 | android:layout_width="fill_parent" |
80 | android:layout_height="wrap_content" | 80 | android:layout_height="wrap_content" |
81 | android:layout_marginLeft="35dp" | 81 | android:layout_marginLeft="35dp" |
82 | android:layout_marginRight="35dp" | 82 | android:layout_marginRight="35dp" |
83 | android:layout_marginTop="16dp" | 83 | android:layout_marginTop="16dp" |
84 | android:orientation="horizontal" > | 84 | android:orientation="horizontal" > |
85 | 85 | ||
86 | <Button | 86 | <Button |
87 | android:id="@+id/gump_reg" | 87 | android:id="@+id/gump_reg" |
88 | android:layout_width="fill_parent" | 88 | android:layout_width="fill_parent" |
89 | android:layout_height="wrap_content" | 89 | android:layout_height="wrap_content" |
90 | android:layout_marginRight="10dp" | 90 | android:layout_marginRight="10dp" |
91 | android:layout_weight="1" | 91 | android:layout_weight="1" |
92 | android:background="@drawable/btn_green_bg" | 92 | android:background="@drawable/btn_green_bg" |
93 | android:text="@string/signup" | 93 | android:text="@string/signup" |
94 | android:textColor="@color/white" /> | 94 | android:textColor="@color/white" /> |
95 | 95 | ||
96 | <Button | 96 | <Button |
97 | android:id="@+id/gump_login" | 97 | android:id="@+id/gump_login" |
98 | android:layout_width="fill_parent" | 98 | android:layout_width="fill_parent" |
99 | android:layout_height="wrap_content" | 99 | android:layout_height="wrap_content" |
100 | android:layout_marginLeft="11dp" | 100 | android:layout_marginLeft="11dp" |
101 | android:layout_weight="1" | 101 | android:layout_weight="1" |
102 | android:background="@drawable/btn_orange_bg" | 102 | android:background="@drawable/btn_orange_bg" |
103 | android:gravity="center" | 103 | android:gravity="center" |
104 | android:text="@string/login" | 104 | android:text="@string/login" |
105 | android:textColor="@android:color/white" | 105 | android:textColor="@android:color/white" |
106 | android:textSize="15sp" | 106 | android:textSize="15sp" |
107 | android:textStyle="bold" /> | 107 | android:textStyle="bold" /> |
108 | </LinearLayout> | 108 | </LinearLayout> |
109 | 109 | ||
110 | <Button | 110 | <Button |
111 | android:id="@+id/play" | 111 | android:id="@+id/play" |
112 | android:layout_width="fill_parent" | 112 | android:layout_width="fill_parent" |
113 | android:layout_height="wrap_content" | 113 | android:layout_height="wrap_content" |
114 | android:layout_marginBottom="16dp" | 114 | android:layout_marginBottom="0dp" |
115 | android:layout_marginLeft="35dp" | 115 | android:layout_marginLeft="35dp" |
116 | android:layout_marginRight="35dp" | 116 | android:layout_marginRight="35dp" |
117 | android:layout_marginTop="16dp" | 117 | android:layout_marginTop="16dp" |
118 | android:background="@drawable/btn_orange_bg" | 118 | android:background="@drawable/btn_orange_bg" |
119 | android:padding="5dp" | 119 | android:padding="5dp" |
120 | android:text="@string/quick_play" | 120 | android:text="@string/quick_play" |
121 | android:textColor="@android:color/white" | 121 | android:textColor="@android:color/white" |
122 | android:textSize="16sp" | 122 | android:textSize="16sp" |
123 | android:textStyle="bold" /> | 123 | android:textStyle="bold" /> |
124 | 124 | ||
125 | <ImageView | 125 | <ImageView |
126 | android:layout_width="fill_parent" | 126 | android:layout_width="fill_parent" |
127 | android:layout_height="wrap_content" | 127 | android:layout_height="wrap_content" |
128 | android:layout_marginLeft="35dp" | 128 | android:layout_marginLeft="35dp" |
129 | android:layout_marginRight="35dp" | 129 | android:layout_marginRight="35dp" |
130 | android:visibility="gone" | ||
130 | android:background="@drawable/horizontal_line" /> | 131 | android:background="@drawable/horizontal_line" /> |
131 | </LinearLayout> | 132 | </LinearLayout> |
132 | 133 | ||
133 | <LinearLayout | 134 | <LinearLayout |
134 | android:layout_width="match_parent" | 135 | android:layout_width="match_parent" |
135 | android:layout_height="wrap_content" | 136 | android:layout_height="wrap_content" |
136 | android:background="@drawable/bottom_light_bg" | 137 | android:background="@drawable/bottom_light_bg" |
137 | android:gravity="center_horizontal" > | 138 | android:gravity="center_horizontal" > |
138 | 139 | ||
139 | </LinearLayout> | 140 | </LinearLayout> |
140 | 141 | ||
141 | </LinearLayout> | 142 | </LinearLayout> |
InlandSDKRelease/res/values/strings.xml
1 | <resources> | 1 | <resources> |
2 | 2 | ||
3 | <string name="user_name_hint">Email</string> | 3 | <string name="user_name_hint">邮箱</string> |
4 | <string name="password_hint">Password</string> | 4 | <string name="password_hint">密码</string> |
5 | <string name="switch_user">Change account</string> | 5 | <string name="switch_user">切换用户</string> |
6 | <string name="loging">Signing...</string> | 6 | <string name="loging">加载中……</string> |
7 | <string name="loading">loading</string> | 7 | <string name="loading">加载中……</string> |
8 | 8 | ||
9 | <string name="signup">Signup</string> | 9 | <string name="signup">注册</string> |
10 | <string name="login">Login</string> | 10 | <string name="login">登录</string> |
11 | <string name="quick_play">Play</string> | 11 | <string name="quick_play">一键登录</string> |
12 | <!-- toast --> | 12 | <!-- toast --> |
13 | <string name="illegal_uname_tip">Invalid Email</string> | 13 | <string name="illegal_uname_tip">请输入正确的邮箱</string> |
14 | <string name="illegal_pwd_tip">Invalid Password (6–20 characters).</string> | 14 | <string name="illegal_pwd_tip">密码格式不正确 (请输入6–20字符)</string> |
15 | <string name="illegal_user_exist">Email has already used</string> | 15 | <string name="illegal_user_exist">邮箱已注册</string> |
16 | <string name="illegal_pwd_invalid">Password is incorrect. Please try again.</string> | 16 | <string name="illegal_pwd_invalid">密码不正确,请重试</string> |
17 | <string name="illegal_user_not_exist">Invalid Email</string> | 17 | <string name="illegal_user_not_exist">邮箱未注册</string> |
18 | <string name="invalid_email">Invalid Email</string> | 18 | <string name="invalid_email">请输入正确的邮箱</string> |
19 | <string name="login_fail">Login failed</string> | 19 | <string name="login_fail">登录失败</string> |
20 | <string name="signup_fail">Signup failed</string> | 20 | <string name="signup_fail">注册失败</string> |
21 | <string name="signup_success">Sign Up Successfully</string> | 21 | <string name="signup_success">注册成功</string> |
22 | <string name="gen_quick_acc_err">Login failed, please try again</string> | 22 | <string name="gen_quick_acc_err">登录失败,请重试</string> |
23 | <string name="quick_login_err">Login failed, please try again</string> | 23 | <string name="quick_login_err">登录失败,请重试</string> |
24 | <string name="net_error">Internet unavailable, please check</string> | 24 | <string name="net_error">网络无法连接,请查看网络设置</string> |
25 | 25 | ||
26 | <string-array name="payment_channel"> | 26 | <string-array name="payment_channel"> |
27 | <item>微信支付</item> | 27 | <item>微信支付</item> |
28 | <item>支付宝</item> | 28 | <item>支付宝</item> |
29 | <item>银联支付</item> | 29 | <item>银联支付</item> |
30 | </string-array> | 30 | </string-array> |
31 | </resources> | 31 | <string-array name="payment_channel_without_wx"> |
32 | <item>支付宝</item> | ||
33 | <item>银联支付</item> | ||
34 | </string-array> | ||
35 | </resources> |
IntegrationGuide.md
1 | ## InlandSDK integration guide | 1 | ## InlandSDK integration guide |
2 | ### 本sdk包含登录和支付功能,支付包含微信支付,支付宝支付和银联支付,因此接入前请申请好各支付渠道的参数 | 2 | ### 本sdk包含登录和支付功能,支付包含微信支付,支付宝支付和银联支付,因此接入前请申请好各支付渠道的参数 |
3 | 1.获取gump分配的appid和appkey | 3 | 1.获取gump分配的appid和appkey |
4 | 2.导入InlandSDK库工程,并将自己的android工程设置引用此库工程 | 4 | 2.导入InlandSDK库工程,并将自己的android工程设置引用此库工程 |
5 | 3.配置AndroidManifest.xml,分为3部分 | 5 | 3.配置AndroidManifest.xml,分为3部分 |
6 | 1)确保有以下permission: | 6 | 1)确保有以下permission: |
7 | 7 | ||
8 | <uses-permission android:name="android.permission.INTERNET" /> | 8 | <uses-permission android:name="android.permission.INTERNET" /> |
9 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | 9 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
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.BLUETOOTH" /> | 11 | <uses-permission android:name="android.permission.BLUETOOTH" /> |
12 | <uses-permission android:name="android.permission.GET_ACCOUNTS" /> | 12 | <uses-permission android:name="android.permission.GET_ACCOUNTS" /> |
13 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | 13 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
14 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | 14 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
15 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> | 15 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> |
16 | <uses-permission android:name="android.permission.WRITE_SETTINGS" /> | 16 | <uses-permission android:name="android.permission.WRITE_SETTINGS" /> |
17 | <!-- 以下是银联支付专用 --> | 17 | <!-- 以下是银联支付专用 --> |
18 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> | 18 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> |
19 | 19 | ||
20 | 2)需要在application内增加如下内容,**微信回调activity必须是 "项目包名.wxapi.WXPayEntryActivity",不可更改,且此activity需继承com.gump.inland.gamesdk.WXPayEntryBaseActivity**: | 20 | 2)需要在application内增加如下内容,**微信回调activity必须是 "项目包名.wxapi.WXPayEntryActivity",不可更改,且此activity需继承com.gump.inland.gamesdk.WXPayEntryBaseActivity**: |
21 | 21 | ||
22 | <activity | 22 | <activity |
23 | android:name="com.gump.inland.gamesdk.PassportBaseActivity" | 23 | android:name="com.gump.inland.gamesdk.PassportBaseActivity" |
24 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | ||
24 | android:theme="@style/Theme.TransparentWin" > | 25 | android:theme="@style/Theme.TransparentWin" > |
25 | </activity> | 26 | </activity> |
26 | <activity | 27 | <activity |
27 | android:name="com.gump.inland.gamesdk.PaymentActivity" | 28 | android:name="com.gump.inland.gamesdk.PaymentActivity" |
28 | android:theme="@android:style/Theme.Light.NoTitleBar" > | 29 | android:theme="@android:style/Theme.Light.NoTitleBar" > |
29 | </activity> | 30 | </activity> |
30 | <!-- wx callback 需要根据规则配置,此处请勿直接拷贝--> | 31 | <!-- wx callback 需要根据规则配置,此处请勿直接拷贝--> |
31 | <activity | 32 | <activity |
32 | android:name="yourPackageName.wxapi.WXPayEntryActivity" | 33 | android:name="yourPackageName.wxapi.WXPayEntryActivity" |
33 | android:exported="true" > | 34 | android:exported="true" > |
34 | </activity> | 35 | </activity> |
35 | <!-- unionPay --> | 36 | <!-- unionPay --> |
36 | <activity | 37 | <activity |
37 | android:name="com.unionpay.uppay.PayActivity" | 38 | android:name="com.unionpay.uppay.PayActivity" |
38 | android:configChanges="orientation|keyboardHidden" | 39 | android:configChanges="orientation|keyboardHidden" |
39 | android:excludeFromRecents="true" | 40 | android:excludeFromRecents="true" |
40 | android:label="@string/app_name" | 41 | android:label="@string/app_name" |
41 | android:screenOrientation="portrait" | 42 | android:screenOrientation="portrait" |
42 | android:windowSoftInputMode="adjustResize" /> | 43 | android:windowSoftInputMode="adjustResize" /> |
44 | <!-- alipay sdk begin --> | ||
45 | <activity | ||
46 | android:name="com.alipay.sdk.app.H5PayActivity" | ||
47 | android:configChanges="orientation|keyboardHidden|navigation" | ||
48 | android:exported="false" | ||
49 | android:screenOrientation="behind" | ||
50 | android:windowSoftInputMode="adjustResize|stateHidden" > | ||
51 | </activity> | ||
52 | <!-- alipay sdk end --> | ||
43 | 53 | ||
44 | 3)为入口activity增加以下Intent-filter,**data scheme配置为微信appid**: | 54 | 3)入口activity增加**android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout"**属性,并增加以下Intent-filter,**data scheme配置为微信appid**: |
45 | 55 | ||
46 | <intent-filter> | 56 | <intent-filter> |
47 | <action android:name="android.intent.action.VIEW" /> | 57 | <action android:name="android.intent.action.VIEW" /> |
48 | 58 | ||
49 | <category android:name="android.intent.category.DEFAULT" /> | 59 | <category android:name="android.intent.category.DEFAULT" /> |
50 | <!-- 此处为微信的appid--> | 60 | <!-- 此处为微信的appid--> |
51 | <data android:scheme="wxdb562d299ac311e0" /> | 61 | <data android:scheme="wxdb562d299ac311e0" /> |
52 | </intent-filter> | 62 | </intent-filter> |
53 | 63 | ||
54 | 4.将InlandSDK工程assets目录下的文件拷贝到游戏项目的assets目录下,此处为银联支付使用 | 64 | 4.将InlandSDKRelease工程assets目录下的文件拷贝到游戏项目的assets目录下,此处为银联支付使用 |
55 | 5.代码接入: | 65 | 5.代码接入: |
56 | 1)sdk初始化,以下方法二选一 | 66 | 1)sdk初始化,以下方法二选一 |
57 | 67 | ||
58 | //若游戏不区分渠道使用此方法 | 68 | //若游戏不区分渠道使用此方法 |
59 | InlandSDK.initializeSDK(gumpAPPId, GumpAPPKey); | 69 | InlandSDK.initializeSDK(gumpAPPId, GumpAPPKey); |
60 | //若游戏区分渠道使用此方法,传入渠道参数 | 70 | //若游戏区分渠道使用此方法,传入渠道参数 |
61 | InlandSDK.initializeSDK(gumpAppId,GumpAPPKey,channel); | 71 | InlandSDK.initializeSDK(gumpAppId,GumpAPPKey,channel); |
62 | 72 | ||
63 | 2)注册登录状态回调: | 73 | 2)注册登录状态回调: |
64 | 74 | ||
65 | Passport.getInstance().registerCallback(new InlandSDKCallback<GumpUser>() { | 75 | Passport.getInstance().registerCallback(new InlandSDKCallback<GumpUser>() { |
66 | 76 | ||
67 | @Override | 77 | @Override |
68 | public void onSuccess(GumpUser result) { | 78 | public void onSuccess(GumpUser result) { |
69 | Logger.d(TAG, "gumpUser:" + result.toString()); | 79 | Logger.d(TAG, "gumpUser:" + result.toString()); |
70 | btnLogin.setVisibility(View.GONE); | 80 | btnLogin.setVisibility(View.GONE); |
71 | tvUserInfo.setText(formatUserInfo(result)); | 81 | tvUserInfo.setText(formatUserInfo(result)); |
72 | btnPay.setVisibility(View.VISIBLE); | 82 | btnPay.setVisibility(View.VISIBLE); |
73 | } | 83 | } |
74 | 84 | ||
75 | @Override | 85 | @Override |
76 | public void onError(InlandSDKException error) { | 86 | public void onError(InlandSDKException error) { |
77 | Logger.d(TAG, "login error:" + error.getMessage()); | 87 | Logger.d(TAG, "login error:" + error.getMessage()); |
78 | } | 88 | } |
79 | 89 | ||
80 | @Override | 90 | @Override |
81 | public void onCancel() { | 91 | public void onCancel() { |
82 | Logger.d(TAG, "login be canceled"); | 92 | Logger.d(TAG, "login be canceled"); |
83 | } | 93 | } |
84 | }); | 94 | }); |
85 | 95 | ||
86 | 3)执行登录操作 | 96 | 3)执行登录操作 |
87 | 97 | ||
88 | Passport.getInstance().login(MainActivity.this); | 98 | Passport.getInstance().login(MainActivity.this); |
89 | 99 | ||
90 | 4)支付操作 | 100 | 4)支付操作 |
91 | 101 | ||
92 | PayRequest payRequest = new PayRequest(); | 102 | PayRequest payRequest = new PayRequest(); |
93 | payRequest.setPrice(1); | 103 | payRequest.setPrice(1); |
94 | payRequest.setProduct("玄冥剑"); | 104 | payRequest.setProduct("玄冥剑"); |
95 | payRequest.setExtOrder("p100201508311730"); | 105 | payRequest.setExtOrder("p100201508311730"); |
96 | payRequest.setGumpUid(Passport.getInstance().getGumpUser().getUid()); | 106 | payRequest.setGumpUid(Passport.getInstance().getGumpUser().getUid()); |
97 | InlandSDK.purchase(MainActivity.this, payRequest, new PurchaseCallback() { | 107 | InlandSDK.purchase(MainActivity.this, payRequest, new PurchaseCallback() { |
98 | 108 | ||
99 | @Override | 109 | @Override |
100 | public void onPurchaseError(Exception e) { | 110 | public void onPurchaseError(Exception e) { |
101 | Logger.w(TAG, "purchase error:" + e.getMessage()); | 111 | Logger.w(TAG, "purchase error:" + e.getMessage()); |
102 | tvPurchaseResult.setText("purchase occured an error:" + e.getMessage()); | 112 | tvPurchaseResult.setText("purchase occured an error:" + e.getMessage()); |
103 | } | 113 | } |
104 | 114 | ||
105 | @Override | 115 | @Override |
106 | public void onPurchaseSuccess(String gumpTransId, String extOrder) { | 116 | public void onPurchaseSuccess(String gumpTransId, String extOrder) { |
107 | Logger.d(TAG, "purchase success:" + gumpTransId + ",extorder:" + extOrder); | 117 | Logger.d(TAG, "purchase success:" + gumpTransId + ",extorder:" + extOrder); |
108 | tvPurchaseResult.setText("purchase " + gumpTransId + " success,extorder:" + extOrder); | 118 | tvPurchaseResult.setText("purchase " + gumpTransId + " success,extorder:" + extOrder); |
109 | } | 119 | } |
110 | 120 | ||
111 | @Override | 121 | @Override |
112 | public void onPurchaseCanceled() { | 122 | public void onPurchaseCanceled() { |
113 | Logger.d(TAG, "purchase be canceled"); | 123 | Logger.d(TAG, "purchase be canceled"); |
114 | tvPurchaseResult.setText("purchase be canceled"); | 124 | tvPurchaseResult.setText("purchase be canceled"); |
115 | } | 125 | } |
116 | }); | 126 | }); |
117 | 127 | ||
118 | 5)配置onActivityResult拦截处理,请在activity的onActivityResult方法内增加InlandSDK的处理方法onActivityResult,当此方法返回true时,说明结果已处理,否则说明未对结果进行处理 | 128 | 5)配置onActivityResult拦截处理,请在activity的onActivityResult方法内增加InlandSDK的处理方法onActivityResult,当此方法返回true时,说明结果已处理,否则说明未对结果进行处理 |
119 | 129 | ||
120 | if (!InlandSDK.onActivityResult(requestCode, resultCode, data)) | 130 | if (!InlandSDK.onActivityResult(requestCode, resultCode, data)) |
121 | super.onActivityResult(requestCode, resultCode, data); | 131 | super.onActivityResult(requestCode, resultCode, data); |