Commit 6519aa98c09345559dc2417e05e2929cc7207ff5
1 parent
82eb378ad8
Exists in
master
删除多余权限
Showing 2 changed files with 14 additions and 24 deletions Inline Diff
android/GameSDKSample/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.loginsdk.sample" | 3 | package="com.loginsdk.sample" |
| 4 | android:versionCode="6" | 4 | android:versionCode="6" |
| 5 | android:versionName="1.6"> | 5 | android:versionName="1.6" > |
| 6 | 6 | ||
| 7 | <uses-sdk | 7 | <uses-sdk |
| 8 | android:minSdkVersion="9" | 8 | android:minSdkVersion="9" |
| 9 | android:targetSdkVersion="22" /> | 9 | android:targetSdkVersion="22" /> |
| 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.READ_PHONE_STATE" /> | 12 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
| 13 | <uses-permission android:name="android.permission.BLUETOOTH" /> | 13 | <uses-permission android:name="android.permission.BLUETOOTH" /> |
| 14 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | 14 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> |
| 15 | <uses-permission android:name="android.permission.WRITE_SETTINGS" /> | 15 | <uses-permission android:name="android.permission.WRITE_SETTINGS" /> |
| 16 | <uses-permission android:name="android.permission.GET_ACCOUNTS" /> | 16 | <uses-permission android:name="android.permission.GET_ACCOUNTS" /> |
| 17 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | 17 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
| 18 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | 18 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
| 19 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> | 19 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> |
| 20 | <!-- upay --> | 20 | <uses-permission android:name="android.permission.SEND_SMS"/> |
| 21 | <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
| 22 | <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | ||
| 23 | <uses-permission android:name="android.permission.VIBRATE" /> | ||
| 24 | <uses-permission android:name="android.permission.SEND_SMS" /> | ||
| 25 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> | ||
| 26 | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> | ||
| 27 | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | ||
| 28 | <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | ||
| 29 | <!-- for card.io card scanning --> | ||
| 30 | <uses-permission android:name="android.permission.CAMERA" /> | ||
| 31 | <!-- coda --> | ||
| 32 | <uses-permission android:name="android.permission.RECEIVE_SMS" /> | ||
| 33 | <uses-permission android:name="android.permission.READ_SMS" /> | ||
| 34 | <uses-permission android:name="android.permission.WRITE_SMS" /> | ||
| 35 | <uses-permission android:name="android.permission.GET_TASKS" /> | ||
| 36 | 21 | ||
| 37 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> | 22 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> |
| 38 | <uses-permission android:name="com.android.vending.BILLING" /> | 23 | <uses-permission android:name="com.android.vending.BILLING" /> |
| 39 | 24 | ||
| 40 | <application | 25 | <application |
| 41 | android:allowBackup="true" | 26 | android:allowBackup="true" |
| 42 | android:icon="@drawable/ic_launcher" | 27 | android:icon="@drawable/ic_launcher" |
| 43 | android:label="@string/app_name"> | 28 | android:label="@string/app_name" > |
| 44 | <activity | 29 | <activity |
| 45 | android:name="com.gumptech.loginsdk.sample.MainActivity" | 30 | android:name="com.gumptech.loginsdk.sample.MainActivity" |
| 46 | android:configChanges="navigation|orientation|keyboard" | 31 | android:configChanges="navigation|orientation|keyboard" |
| 47 | android:label="@string/app_name" | 32 | android:label="@string/app_name" |
| 48 | android:screenOrientation="portrait"> | 33 | android:screenOrientation="portrait" > |
| 49 | <intent-filter> | 34 | <intent-filter> |
| 50 | <action android:name="android.intent.action.MAIN" /> | 35 | <action android:name="android.intent.action.MAIN" /> |
| 51 | 36 | ||
| 52 | <category android:name="android.intent.category.LAUNCHER" /> | 37 | <category android:name="android.intent.category.LAUNCHER" /> |
| 53 | </intent-filter> | 38 | </intent-filter> |
| 54 | </activity> | 39 | </activity> |
| 55 | <activity | 40 | <activity |
| 56 | android:name="com.gumptech.sdk.ContainerActivity" | 41 | android:name="com.gumptech.sdk.ContainerActivity" |
| 57 | android:configChanges="orientation|screenLayout" | 42 | android:configChanges="orientation|screenLayout" |
| 58 | android:theme="@style/container_dialog"></activity> | 43 | android:theme="@style/container_dialog" > |
| 44 | </activity> | ||
| 59 | <activity | 45 | <activity |
| 60 | android:name="com.gumptech.sdk.PaymentActivity" | 46 | android:name="com.gumptech.sdk.PaymentActivity" |
| 61 | android:configChanges="orientation|screenLayout" | 47 | android:configChanges="orientation|screenLayout" |
| 62 | android:theme="@android:style/Theme.Translucent.NoTitleBar"></activity> | 48 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > |
| 49 | </activity> | ||
| 63 | <activity | 50 | <activity |
| 64 | android:name="com.gumptech.sdk.ExchangeWindow" | 51 | android:name="com.gumptech.sdk.ExchangeWindow" |
| 65 | android:configChanges="orientation|screenLayout" | 52 | android:configChanges="orientation|screenLayout" |
| 66 | android:theme="@style/ex_win"></activity> | 53 | android:theme="@style/ex_win" > |
| 54 | </activity> | ||
| 67 | 55 | ||
| 68 | <service android:name="com.gumptech.sdk.PushService"></service> | 56 | <service android:name="com.gumptech.sdk.PushService" > |
| 57 | </service> | ||
| 69 | 58 | ||
| 59 | <!-- facebook --> | ||
| 70 | <activity | 60 | <activity |
| 71 | android:name="com.facebook.FacebookActivity" | 61 | android:name="com.facebook.FacebookActivity" |
| 72 | android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" | 62 | android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" |
android/GameSDKSample/src/com/gumptech/loginsdk/sample/MainActivity.java
| 1 | package com.gumptech.loginsdk.sample; | 1 | package com.gumptech.loginsdk.sample; |
| 2 | 2 | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | import android.content.Intent; | 4 | import android.content.Intent; |
| 5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
| 6 | import android.util.Log; | 6 | import android.util.Log; |
| 7 | import android.view.View; | 7 | import android.view.View; |
| 8 | import android.widget.Button; | 8 | import android.widget.Button; |
| 9 | import android.widget.TextView; | 9 | import android.widget.TextView; |
| 10 | import android.widget.Toast; | 10 | import android.widget.Toast; |
| 11 | 11 | ||
| 12 | import com.gumptech.sdk.GumpSDK; | 12 | import com.gumptech.sdk.GumpSDK; |
| 13 | import com.gumptech.sdk.bean.GumpUser; | 13 | import com.gumptech.sdk.bean.GumpUser; |
| 14 | import com.gumptech.sdk.bean.PurchaseResult; | 14 | import com.gumptech.sdk.bean.PurchaseResult; |
| 15 | import com.gumptech.sdk.callback.InitializeCallback; | 15 | import com.gumptech.sdk.callback.InitializeCallback; |
| 16 | import com.gumptech.sdk.callback.LoginStateListener; | 16 | import com.gumptech.sdk.callback.LoginStateListener; |
| 17 | import com.gumptech.sdk.callback.PurchaseCallback; | 17 | import com.gumptech.sdk.callback.PurchaseCallback; |
| 18 | import com.loginsdk.sample.R; | 18 | import com.loginsdk.sample.R; |
| 19 | 19 | ||
| 20 | public class MainActivity extends Activity implements PurchaseCallback{ | 20 | public class MainActivity extends Activity implements PurchaseCallback{ |
| 21 | 21 | ||
| 22 | private static final String TAG = "MainActivity"; | 22 | private static final String TAG = "MainActivity"; |
| 23 | 23 | ||
| 24 | private TextView tvVersion; | 24 | private TextView tvVersion; |
| 25 | private TextView userInfo; | 25 | private TextView userInfo; |
| 26 | 26 | ||
| 27 | private Button btnLoginOrLogout; | 27 | private Button btnLoginOrLogout; |
| 28 | 28 | ||
| 29 | private String appId = "10022"; | 29 | private String appId = "10022"; |
| 30 | private String appKey = "93a27b0bd99bac3e68a440b48aa421ab"; | 30 | private String appKey = "93a27b0bd99bac3e68a440b48aa421ab"; |
| 31 | 31 | ||
| 32 | @Override | 32 | @Override |
| 33 | protected void onCreate(Bundle savedInstanceState) { | 33 | protected void onCreate(Bundle savedInstanceState) { |
| 34 | super.onCreate(savedInstanceState); | 34 | super.onCreate(savedInstanceState); |
| 35 | setContentView(R.layout.activity_main); | 35 | setContentView(R.layout.activity_main); |
| 36 | tvVersion = (TextView) findViewById(R.id.version); | 36 | tvVersion = (TextView) findViewById(R.id.version); |
| 37 | userInfo = (TextView) findViewById(R.id.user_info); | 37 | userInfo = (TextView) findViewById(R.id.user_info); |
| 38 | btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); | 38 | btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); |
| 39 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { | 39 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { |
| 40 | 40 | ||
| 41 | @Override | 41 | @Override |
| 42 | public void onClick(View v) { | 42 | public void onClick(View v) { |
| 43 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) | 43 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) |
| 44 | GumpSDK.start(MainActivity.this); | 44 | GumpSDK.start(MainActivity.this); |
| 45 | else | 45 | else |
| 46 | GumpSDK.logout(MainActivity.this); | 46 | GumpSDK.logout(MainActivity.this); |
| 47 | } | 47 | } |
| 48 | }); | 48 | }); |
| 49 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { | 49 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { |
| 50 | 50 | ||
| 51 | @Override | 51 | @Override |
| 52 | public void onClick(View v) { | 52 | public void onClick(View v) { |
| 53 | Bundle payInfo = new Bundle(); | 53 | Bundle payInfo = new Bundle(); |
| 54 | payInfo.putString("nick", "thi"); | 54 | payInfo.putString("nick", "thi"); |
| 55 | payInfo.putString("product", "元宝"); | 55 | payInfo.putString("product", "元宝"); |
| 56 | payInfo.putFloat("amount", 0.0f); | 56 | payInfo.putFloat("amount", 0.0f); |
| 57 | payInfo.putString("extraInfo", "This is demo!"); | 57 | payInfo.putString("extraInfo", "This is demo!"); |
| 58 | payInfo.putString("serverId", "5001"); | 58 | payInfo.putString("serverId", "5001"); |
| 59 | GumpSDK.pay(MainActivity.this, payInfo, "3332768", MainActivity.this); | 59 | GumpSDK.pay(MainActivity.this, payInfo, "3332768", MainActivity.this); |
| 60 | } | 60 | } |
| 61 | }); | 61 | }); |
| 62 | GumpSDK.setDebugState(true); | 62 | GumpSDK.setDebugState(true); |
| 63 | GumpSDK.setLogoShow(true); | 63 | GumpSDK.setLogoShow(true); |
| 64 | GumpSDK.setScreenLandscape(false); | 64 | GumpSDK.setScreenLandscape(false); |
| 65 | GumpSDK.setUserStateListener(new LoginStateListener() { | 65 | GumpSDK.setUserStateListener(new LoginStateListener() { |
| 66 | @Override | 66 | @Override |
| 67 | public void onLoginSuccess(GumpUser user) { | 67 | public void onLoginSuccess(GumpUser user) { |
| 68 | userInfo.setText("Userid:" + user.getUid() + "\n accountType:" + user.getAccountType() + "\n sessionKey:" + user.getSessionKey()); | 68 | userInfo.setText("Userid:" + user.getUid() + "\n accountType:" + user.getAccountType() + "\n sessionKey:" + user.getSessionKey()); |
| 69 | btnLoginOrLogout.setText("Logout"); | 69 | btnLoginOrLogout.setText("Logout"); |
| 70 | btnLoginOrLogout.setTag(1); | 70 | btnLoginOrLogout.setTag(1); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | @Override | 73 | @Override |
| 74 | public void onLoginFailed(int code, String msg) { | 74 | public void onLoginFailed(int code, String msg) { |
| 75 | userInfo.setText(msg); | 75 | userInfo.setText(msg); |
| 76 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); | 76 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | @Override | 79 | @Override |
| 80 | public void onLoginCanceled() { | 80 | public void onLoginCanceled() { |
| 81 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 81 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | @Override | 84 | @Override |
| 85 | public void onLogout() { | 85 | public void onLogout() { |
| 86 | btnLoginOrLogout.setText("Login"); | 86 | btnLoginOrLogout.setText("Login"); |
| 87 | btnLoginOrLogout.setTag(0); | 87 | btnLoginOrLogout.setTag(0); |
| 88 | userInfo.setText("User is logout"); | 88 | userInfo.setText("User is logout"); |
| 89 | } | 89 | } |
| 90 | }); | 90 | }); |
| 91 | GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { | 91 | GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { |
| 92 | @Override | 92 | @Override |
| 93 | public void initComplete(int result) { | 93 | public void initComplete(int result) { |
| 94 | if (result == GumpSDK.CODE.OK) { | 94 | if (result == GumpSDK.CODE.OK) { |
| 95 | btnLoginOrLogout.setEnabled(true); | 95 | btnLoginOrLogout.setEnabled(true); |
| 96 | } | 96 | } |
| 97 | } | 97 | } |
| 98 | }); | 98 | }); |
| 99 | 99 | ||
| 100 | 100 | ||
| 101 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); | 101 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | @Override | 104 | @Override |
| 105 | public void onPurchaseCompleted(PurchaseResult result) { | 105 | public void onPurchaseCompleted(PurchaseResult result) { |
| 106 | Log.i(TAG,"purchase completed"); | 106 | Log.i(TAG,"purchase completed"); |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | @Override | 109 | @Override |
| 110 | public void onPurchaseError(int code, String msg) { | 110 | public void onPurchaseError(int code, String msg) { |
| 111 | Log.i(TAG,"purchase error"); | 111 | Log.i(TAG,"purchase error"); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | @Override | 114 | @Override |
| 115 | public void onPurchaseCanceled() { | 115 | public void onPurchaseCanceled() { |
| 116 | Log.i(TAG,"purchase canceled"); | 116 | Log.i(TAG,"purchase canceled"); |
| 117 | } | 117 | } |
| 118 | } | 118 | } |
| 119 | 119 |