sdk工程加入猕猴桃sdk
parent
7605156317
commit
037290c657
Binary file not shown.
|
@ -3,9 +3,8 @@
|
|||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="LOCAL" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-4.6" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="svn" />
|
||||
</component>
|
||||
</project>
|
|
@ -30,6 +30,8 @@ android {
|
|||
makeJar.dependsOn(build)
|
||||
|
||||
|
||||
repositories { flatDir { dirs 'libs' } }
|
||||
defaultConfig { ndk { abiFilters 'armeabi' }}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -37,20 +39,32 @@ dependencies {
|
|||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
implementation files('libs/sjsdklibrary_3.1.1_5119.jar')
|
||||
implementation files('libs/ktdeviceutil_1.5.jar')
|
||||
implementation files('libs/classes.jar')
|
||||
// common
|
||||
implementation files('libs/android-support-v4.jar')
|
||||
implementation files('libs/android-support-multidex.jar')
|
||||
implementation files('libs/adapter-rxjava-2.4.0.jar')
|
||||
implementation files('libs/converter-fastjson-2.1.0.jar')
|
||||
implementation files('libs/fastjson-1.1.68.android.jar')
|
||||
implementation files('libs/logging-interceptor-3.11.0.jar')
|
||||
implementation files('libs/okhttp-3.11.0.jar')
|
||||
implementation files('libs/okio-1.14.0.jar')
|
||||
implementation files('libs/org.apache.http.legacy.jar')
|
||||
implementation files('libs/permissionutil.jar')
|
||||
implementation files('libs/retrofit-2.4.0.jar')
|
||||
implementation files('libs/rxandroid-1.2.1.jar')
|
||||
implementation files('libs/rxjava-1.3.8.jar')
|
||||
implementation files('libs/wechat-sdk.jar')
|
||||
// ⨺ïÌÒ
|
||||
implementation files('libs/PSDK/GDTActionSDK.min.1.6.4.aar')
|
||||
implementation files('libs/PSDK/mhtsdk.aar')
|
||||
implementation files('libs/PSDK/onelogin.aar')
|
||||
implementation files('libs/PSDK/RangersAppLog-Lite-cn-3.3.12.aar')
|
||||
implementation files('libs/PSDK/psdk_mht.aar')
|
||||
implementation files('libs/PSDK/psdk.aar')
|
||||
implementation files('libs/PSDK/miit_mdid_1.0.10.aar')
|
||||
// ¿ªÌì
|
||||
implementation files('libs/KTSDK/adapter-rxjava-2.4.0.jar')
|
||||
implementation files('libs/KTSDK/converter-fastjson-2.1.0.jar')
|
||||
implementation files('libs/KTSDK/fastjson-1.1.68.android.jar')
|
||||
implementation files('libs/KTSDK/ktdeviceutil_1.5.jar')
|
||||
implementation files('libs/KTSDK/logging-interceptor-3.11.0.jar')
|
||||
implementation files('libs/KTSDK/okhttp-3.11.0.jar')
|
||||
implementation files('libs/KTSDK/okio-1.14.0.jar')
|
||||
implementation files('libs/KTSDK/org.apache.http.legacy.jar')
|
||||
implementation files('libs/KTSDK/permissionutil.jar')
|
||||
implementation files('libs/KTSDK/retrofit-2.4.0.jar')
|
||||
implementation files('libs/KTSDK/rxandroid-1.2.1.jar')
|
||||
implementation files('libs/KTSDK/rxjava-1.3.8.jar')
|
||||
implementation files('libs/KTSDK/sjsdklibrary_3.1.1_5119.jar')
|
||||
// unity
|
||||
implementation files('libs/Unity/classes.jar')
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,11 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.bluewhale.jieling">
|
||||
package="com.mht.tcxcsb.project">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:supportsRtl="true">
|
||||
<activity android:name=".MainActivity">
|
||||
<activity android:name=".MhtActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
|
|
@ -13,6 +13,9 @@ import android.telephony.TelephonyManager;
|
|||
import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.ktgame.ktdeviceutil.KTGameDeviceUtil;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
|
@ -148,4 +151,14 @@ public class AndroidDeviceInfo {
|
|||
result = charSequence.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
public String GetIMEICode(Context context) {
|
||||
return KTGameDeviceUtil.getIMEI(context);
|
||||
}
|
||||
|
||||
public String GetDeviceID(Context context) {
|
||||
return KTGameDeviceUtil.getDeviceID(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,234 @@
|
|||
package com.bluewhale.androidutils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class NotchScreenUtil {
|
||||
|
||||
|
||||
private static NotchScreenUtil _instance = null;
|
||||
public static NotchScreenUtil instance() {
|
||||
if (_instance == null)
|
||||
_instance = new NotchScreenUtil();
|
||||
return _instance;
|
||||
}
|
||||
|
||||
private static Context mContext;
|
||||
public void Init(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* 华为start
|
||||
*/
|
||||
// 判断是否是华为刘海屏
|
||||
private static boolean hasNotchInScreenAtHuawei() {
|
||||
boolean ret = false;
|
||||
try {
|
||||
ClassLoader cl = mContext.getClassLoader();
|
||||
Class<?> HwNotchSizeUtil = cl.loadClass("com.huawei.android.util.HwNotchSizeUtil");
|
||||
Method get = HwNotchSizeUtil.getMethod("hasNotchInScreen");
|
||||
ret = (Boolean) get.invoke(HwNotchSizeUtil);
|
||||
Log.d("NotchScreenUtil", "this Huawei device has notch in screen?"+ret);
|
||||
} catch (ClassNotFoundException e) {
|
||||
Log.e("NotchScreenUtil", "hasNotchInScreen ClassNotFoundException", e);
|
||||
} catch (NoSuchMethodException e) {
|
||||
Log.e("NotchScreenUtil", "hasNotchInScreen NoSuchMethodException", e);
|
||||
} catch (Exception e) {
|
||||
Log.e("NotchScreenUtil", "hasNotchInScreen Exception", e);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取华为刘海的高
|
||||
* @return
|
||||
*/
|
||||
private static int getNotchSizeAtHuawei() {
|
||||
int[] ret = new int[] { 0, 0 };
|
||||
try {
|
||||
ClassLoader cl = mContext.getClassLoader();
|
||||
Class<?> HwNotchSizeUtil = cl.loadClass("com.huawei.android.util.HwNotchSizeUtil");
|
||||
Method get = HwNotchSizeUtil.getMethod("getNotchSize");
|
||||
ret = (int[]) get.invoke(HwNotchSizeUtil);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
Log.e("NotchScreenUtil", "getNotchSize ClassNotFoundException");
|
||||
} catch (NoSuchMethodException e) {
|
||||
Log.e("NotchScreenUtil", "getNotchSize NoSuchMethodException");
|
||||
} catch (Exception e) {
|
||||
Log.e("NotchScreenUtil", "getNotchSize Exception");
|
||||
}
|
||||
return ret[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* 华为end
|
||||
*/
|
||||
|
||||
/**
|
||||
* Oppo start
|
||||
*/
|
||||
private static boolean hasNotchInScreenAtOppo() {
|
||||
boolean hasNotch = mContext.getPackageManager().hasSystemFeature("com.oppo.feature.screen.heteromorphism");
|
||||
Log.d("NotchScreenUtil", "this OPPO device has notch in screen?"+hasNotch);
|
||||
return hasNotch;
|
||||
}
|
||||
|
||||
private static int getNotchSizeAtOppo() {
|
||||
return 80;
|
||||
}
|
||||
|
||||
/**
|
||||
* Oppo end
|
||||
*/
|
||||
|
||||
/**
|
||||
* vivo start
|
||||
*/
|
||||
private static final int NOTCH_IN_SCREEN_VOIO = 0x00000020;// 是否有凹槽
|
||||
private static final int ROUNDED_IN_SCREEN_VOIO = 0x00000008;// 是否有圆角
|
||||
|
||||
private static boolean hasNotchInScreenAtVivo() {
|
||||
boolean ret = false;
|
||||
try {
|
||||
ClassLoader cl = mContext.getClassLoader();
|
||||
Class<?> FtFeature = cl.loadClass("com.util.FtFeature");
|
||||
Method get = FtFeature.getMethod("isFeatureSupport", int.class);
|
||||
ret = (Boolean) get.invoke(FtFeature, NOTCH_IN_SCREEN_VOIO);
|
||||
Log.d("NotchScreenUtil", "this VIVO device has notch in screen?" + ret);
|
||||
} catch (ClassNotFoundException e) {
|
||||
Log.e("NotchScreenUtil", "hasNotchInScreen ClassNotFoundException", e);
|
||||
} catch (NoSuchMethodException e) {
|
||||
Log.e("NotchScreenUtil", "hasNotchInScreen NoSuchMethodException", e);
|
||||
} catch (Exception e) {
|
||||
Log.e("NotchScreenUtil", "hasNotchInScreen Exception", e);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static int getNotchSizeAtVivo(){
|
||||
return dp2px(mContext, 32);
|
||||
}
|
||||
|
||||
/**
|
||||
* vivo end
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* dp转px
|
||||
* @param context
|
||||
* @param dpValue
|
||||
* @return
|
||||
*/
|
||||
private static int dp2px(Context context, int dpValue) {
|
||||
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpValue,context.getResources().getDisplayMetrics());
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 判断小米手机
|
||||
* @return
|
||||
*/
|
||||
private static boolean hasNotchInScreenAtXIAOMI() {
|
||||
boolean ret = false;
|
||||
try {
|
||||
ClassLoader cl = mContext.getClassLoader();
|
||||
Class<?> SystemProperties = cl.loadClass("android.os.SystemProperties");
|
||||
|
||||
Class[] paramTypes = new Class[2];
|
||||
paramTypes[0] = String.class;
|
||||
paramTypes[1] = int.class;
|
||||
Method get = SystemProperties.getMethod("getInt", paramTypes);
|
||||
|
||||
Object[] params = new Object[2];
|
||||
params[0] = "ro.miui.notch";
|
||||
params[1] = 0;
|
||||
ret = (Integer) get.invoke(SystemProperties, params) == 1;
|
||||
Log.d("NotchScreenUtil", "this XIAOMI device has notch in screen?" + ret);
|
||||
} catch (ClassNotFoundException e) {
|
||||
Log.e("NotchScreenUtil", "hasNotchInScreen ClassNotFoundException", e);
|
||||
} catch (NoSuchMethodException e) {
|
||||
Log.e("NotchScreenUtil", "hasNotchInScreen NoSuchMethodException", e);
|
||||
} catch (Exception e) {
|
||||
Log.e("NotchScreenUtil", "hasNotchInScreen Exception", e);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小米手机
|
||||
* @return
|
||||
*/
|
||||
private static int getNotchSizeAtXIAOMI(){
|
||||
int resourceId = mContext.getResources().getIdentifier("notch_height", "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
return mContext.getResources().getDimensionPixelSize(resourceId);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取手机厂商
|
||||
*
|
||||
* @return 手机厂商
|
||||
*/
|
||||
private final static int DEVICE_BRAND_OPPO = 0x0001;
|
||||
private final static int DEVICE_BRAND_HUAWEI = 0x0002;
|
||||
private final static int DEVICE_BRAND_VIVO = 0x0003;
|
||||
private final static int DEVICE_BRAND_XIAOMI = 0x0004;
|
||||
|
||||
private static int getDeviceBrand() {
|
||||
String brand = android.os.Build.BRAND.trim().toUpperCase();
|
||||
if (brand.contains("HUAWEI")) {
|
||||
Log.d("device brand", "HUAWEI");
|
||||
return DEVICE_BRAND_HUAWEI;
|
||||
}else if (brand.contains("OPPO")) {
|
||||
Log.d("device brand", "OPPO");
|
||||
return DEVICE_BRAND_OPPO;
|
||||
}else if (brand.contains("VIVO")) {
|
||||
Log.d("device brand", "VIVO");
|
||||
return DEVICE_BRAND_VIVO;
|
||||
}else if (brand.contains("MI")) {
|
||||
Log.d("device brand", "XIAOMI");
|
||||
return DEVICE_BRAND_XIAOMI;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public static int getNotchHeight(){
|
||||
int brand = getDeviceBrand();
|
||||
switch (brand){
|
||||
case DEVICE_BRAND_HUAWEI:
|
||||
if(hasNotchInScreenAtHuawei()) return getNotchSizeAtHuawei();
|
||||
break;
|
||||
|
||||
case DEVICE_BRAND_OPPO:
|
||||
if(hasNotchInScreenAtOppo()) return getNotchSizeAtOppo();
|
||||
break;
|
||||
|
||||
case DEVICE_BRAND_VIVO:
|
||||
if(hasNotchInScreenAtVivo()) return getNotchSizeAtVivo();
|
||||
break;
|
||||
|
||||
case DEVICE_BRAND_XIAOMI:
|
||||
if(hasNotchInScreenAtXIAOMI()) return getNotchSizeAtXIAOMI();
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.bluewhale.jieling;
|
||||
|
||||
import android.graphics.BitmapFactory;
|
||||
|
||||
import com.unity3d.player.UnityPlayerActivity;
|
||||
|
||||
public abstract class IUnityPlayerActivity extends UnityPlayerActivity {
|
||||
|
||||
public final String SUCCESS = "1";
|
||||
public final String FAILED = "0";
|
||||
// 初始化接口
|
||||
public abstract void Init();
|
||||
// 登录接口
|
||||
public abstract void Login();
|
||||
public abstract void SwitchLogin();
|
||||
public abstract void Logout();
|
||||
// 数据提交接口
|
||||
public abstract void SubmitExtraData(
|
||||
final int dataType,
|
||||
final int serverId,
|
||||
final String serverName,
|
||||
final String zoneID,
|
||||
final String zoneName,
|
||||
final String roleID,
|
||||
final String roleName,
|
||||
final String roleLevel,
|
||||
String guildlD,
|
||||
String Vip,
|
||||
final int moneyNum,
|
||||
final String roleCreateTime,
|
||||
final String roleLevelUpTime);
|
||||
//支付接口
|
||||
public abstract void Pay(
|
||||
final String productId,
|
||||
final String productName,
|
||||
final String productDesc,
|
||||
final int price,
|
||||
final int ratio,
|
||||
final int buyNum,
|
||||
final int coinNum,
|
||||
final String zoneId,
|
||||
final String serverID,
|
||||
final String serverName,
|
||||
String accounted,
|
||||
final String roleID,
|
||||
final String roleName,
|
||||
final int roleLevel,
|
||||
final String vip,
|
||||
final String guildlD,
|
||||
String payNotifyUrl,
|
||||
final String extension);
|
||||
// 手机返回键点击事件
|
||||
public abstract void ExitGame();
|
||||
//是否支持退出功能
|
||||
public abstract boolean IsSupportExit();
|
||||
// 获取订单ID
|
||||
public abstract String GetOrderID();
|
||||
// 截屏功能
|
||||
public abstract void SendScreenshotData(byte[] bytes);
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ import android.content.res.Configuration;
|
|||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import com.ktgame.ktdeviceutil.KTGameDeviceUtil;
|
||||
|
||||
import com.ktgame.sj.bean.SJPayParams;
|
||||
import com.ktgame.sj.bean.SJUserExtraData;
|
||||
import com.ktgame.sj.callinterface.ISJSDKListener;
|
||||
|
@ -22,14 +22,33 @@ import com.ktgame.sj.plugin.SJPay;
|
|||
import com.ktgame.sj.plugin.SJUser;
|
||||
import com.ktgame.sj.verify.UToken;
|
||||
import com.unity3d.player.UnityPlayer;
|
||||
import com.unity3d.player.UnityPlayerActivity;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import static android.content.Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT;
|
||||
|
||||
public class MainActivity extends UnityPlayerActivity {
|
||||
private boolean mRepeatCreate;
|
||||
public class MainActivity extends IUnityPlayerActivity {
|
||||
private final int CODE_NO_NETWORK = 0;
|
||||
private final int CODE_INIT_SUCCESS = 1;
|
||||
private final int CODE_INIT_FAIL = 2;
|
||||
private final int CODE_LOGIN_SUCCESS = 3;
|
||||
private final int CODE_LOGIN_FAIL = 4;
|
||||
private final int CODE_LOGIN_CANCEL = 5;
|
||||
private final int CODE_AUTH_TOKEN_SUCCESS = 6;
|
||||
private final int CODE_AUTH_TOKEN_FAIL = 7;
|
||||
private final int CODE_SW_LOGIN_SUCCESS = 8;
|
||||
private final int CODE_SW_LOGIN_FAIL = 9;
|
||||
private final int CODE_LOGOUT_SUCCESS = 10;
|
||||
private final int CODE_LOGOUT_FAIL = 11;
|
||||
private final int CODE_PAY_SUCCESS = 12;
|
||||
private final int CODE_PAY_FAIL = 13;
|
||||
private final int CODE_PAY_CANCEL = 14;
|
||||
private final int CODE_PAY_UNKNOWN = 15;
|
||||
private final int CODE_PAYING = 16;
|
||||
private final int CODE_REAL_NAME_REG_SUC = 17;
|
||||
private final int CODE_SHARE_SUCCESS = 18;
|
||||
private final int CODE_SHARE_FAIL = 19;
|
||||
private final int CODE_SHARE_CANCEL = 20;
|
||||
|
||||
private String TAG = "BlueWhale-JieLing";
|
||||
|
||||
|
@ -41,14 +60,77 @@ public class MainActivity extends UnityPlayerActivity {
|
|||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
init();
|
||||
InitSJ();
|
||||
Init();
|
||||
SJSDK.getInstance().onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
public void onStart() {
|
||||
SJSDK.getInstance().onStart();
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
SJSDK.getInstance().onPause();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
SJSDK.getInstance().onResume();
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
SJSDK.getInstance().onActivityResult(requestCode, resultCode, data);
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
public void onNewIntent(Intent newIntent) {
|
||||
SJSDK.getInstance().onNewIntent(newIntent);
|
||||
super.onNewIntent(newIntent);
|
||||
}
|
||||
|
||||
public void onStop() {
|
||||
SJSDK.getInstance().onStop();
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
SJSDK.getInstance().onDestroy();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public void onRestart() {
|
||||
SJSDK.getInstance().onRestart();
|
||||
super.onRestart();
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
@TargetApi(23)
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
SJSDK.getInstance().onRequestPermissionResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
public void attachBaseContext(Context newBase) {
|
||||
super.attachBaseContext(newBase);
|
||||
SJSDK.getInstance().attachBaseContext(newBase);
|
||||
}
|
||||
|
||||
public void Init() {
|
||||
if ((getIntent().getFlags() & FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
|
||||
Log.i(this.TAG, "onCreate with flag FLAG_ACTIVITY_BROUGHT_TO_FRONT");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
InitSJ();
|
||||
// 监听截屏事件
|
||||
SJSDK.getInstance().setmSlistener(new IScreenshotListener() {
|
||||
@SuppressLint({"SimpleDateFormat"})
|
||||
public Bitmap createScreenshot() {
|
||||
if (MainActivity.this.bitmap == null)
|
||||
UnityPlayer.UnitySendMessage("KTSDKHelper", "CaptureShot", "");
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "CaptureShot", "");
|
||||
while (MainActivity.this.bitmap == null) {
|
||||
try {
|
||||
Thread.sleep(500L);
|
||||
|
@ -70,19 +152,6 @@ public class MainActivity extends UnityPlayerActivity {
|
|||
});
|
||||
}
|
||||
|
||||
public void SendScreenshotData(byte[] bytes) {
|
||||
this.bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if ((getIntent().getFlags() & FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
|
||||
Log.i(this.TAG, "onCreate with flag FLAG_ACTIVITY_BROUGHT_TO_FRONT");
|
||||
this.mRepeatCreate = true;
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitSJ() {
|
||||
int appid = 129213;
|
||||
String appkey = "c0fb59eb68559b6c9c1463e4d5d0c806";
|
||||
|
@ -90,92 +159,6 @@ public class MainActivity extends UnityPlayerActivity {
|
|||
InitLaunch(appid, appkey, privatekey);
|
||||
}
|
||||
|
||||
public void onStart() {
|
||||
SJSDK.getInstance().onStart();
|
||||
super.onStart();
|
||||
if (this.mRepeatCreate) {
|
||||
Log.i(this.TAG, "onStart is repeat activity!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
SJSDK.getInstance().onPause();
|
||||
super.onPause();
|
||||
if (this.mRepeatCreate) {
|
||||
Log.i(this.TAG, "onPause is repeat activity!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
SJSDK.getInstance().onResume();
|
||||
super.onResume();
|
||||
if (this.mRepeatCreate) {
|
||||
Log.i(this.TAG, "onResume is repeat activity!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
SJSDK.getInstance().onActivityResult(requestCode, resultCode, data);
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
public void onNewIntent(Intent newIntent) {
|
||||
SJSDK.getInstance().onNewIntent(newIntent);
|
||||
super.onNewIntent(newIntent);
|
||||
if (this.mRepeatCreate) {
|
||||
Log.i(this.TAG, "onNewIntent is repeat activity!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void onStop() {
|
||||
SJSDK.getInstance().onStop();
|
||||
super.onStop();
|
||||
if (this.mRepeatCreate) {
|
||||
Log.i(this.TAG, "onStop is repeat activity!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
SJSDK.getInstance().onDestroy();
|
||||
super.onDestroy();
|
||||
if (this.mRepeatCreate) {
|
||||
Log.i(this.TAG, "onDestroy is repeat activity!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void onRestart() {
|
||||
SJSDK.getInstance().onRestart();
|
||||
super.onRestart();
|
||||
if (this.mRepeatCreate) {
|
||||
Log.i(this.TAG, "onRestart is repeat activity!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
if (this.mRepeatCreate) {
|
||||
Log.i(this.TAG, "onConfigurationChanged is repeat activity!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(23)
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
SJSDK.getInstance().onRequestPermissionResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
public void attachBaseContext(Context newBase) {
|
||||
super.attachBaseContext(newBase);
|
||||
SJSDK.getInstance().attachBaseContext(newBase);
|
||||
}
|
||||
|
||||
public void InitLaunch(int appid, String appkey, String privateKey) {
|
||||
SJSDK.getInstance().init((Activity)this, appid, appkey, privateKey, new ISJSDKListener() {
|
||||
public void onResult(int code, final String message) {
|
||||
|
@ -189,7 +172,8 @@ public class MainActivity extends UnityPlayerActivity {
|
|||
public void onSwitchAccount(final int code, final String message) {
|
||||
MainActivity.this.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
UnityPlayer.UnitySendMessage("KTSDKHelper", "SwitchAccountCallback", String.valueOf(code) + "#" + message);
|
||||
String result = code == CODE_SW_LOGIN_SUCCESS ? SUCCESS : FAILED;
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "SwitchAccountCallback", result + "#" + message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -197,15 +181,17 @@ public class MainActivity extends UnityPlayerActivity {
|
|||
public void onSwitchAccount(final int code) {
|
||||
MainActivity.this.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
UnityPlayer.UnitySendMessage("KTSDKHelper", "SwitchAccountCallback", String.valueOf(code) + "#");
|
||||
String result = code == CODE_SW_LOGIN_SUCCESS ? SUCCESS : FAILED;
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "SwitchAccountCallback", result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onPayResult(final int code, final String result) {
|
||||
public void onPayResult(final int code, final String r) {
|
||||
MainActivity.this.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
UnityPlayer.UnitySendMessage("KTSDKHelper", "PayCallback", String.valueOf(code) + "#" + result);
|
||||
String result = code == CODE_PAY_SUCCESS ? SUCCESS : FAILED;
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "PayCallback", result + "#" + GetOrderID());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -213,8 +199,8 @@ public class MainActivity extends UnityPlayerActivity {
|
|||
public void onLogout(final int code) {
|
||||
MainActivity.this.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if (code != 10);
|
||||
UnityPlayer.UnitySendMessage("KTSDKHelper", "LogoutCallback", String.valueOf(code) + "#");
|
||||
String result = code == CODE_LOGOUT_SUCCESS ? SUCCESS : FAILED;
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "LogoutCallback", result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -223,10 +209,8 @@ public class MainActivity extends UnityPlayerActivity {
|
|||
Log.d("SJSDK", "The sdk login result is " + result);
|
||||
MainActivity.this.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if (code != 3)
|
||||
if (code != 4)
|
||||
if (code == 5)
|
||||
MainActivity.this.logincancel();
|
||||
if (code == CODE_LOGIN_CANCEL)
|
||||
MainActivity.this.logincancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -234,11 +218,8 @@ public class MainActivity extends UnityPlayerActivity {
|
|||
public void onInitResult(final int code, final String result) {
|
||||
MainActivity.this.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if (code == 1) {
|
||||
String logicChannel = SJSDK.getInstance().getLogicChannel();
|
||||
Log.e("SJSDK", "logicChannel=" + logicChannel);
|
||||
}
|
||||
UnityPlayer.UnitySendMessage("KTSDKHelper", "InitCallback", String.valueOf(code) + "#" + result);
|
||||
String result = code == CODE_INIT_SUCCESS ? SUCCESS : FAILED;
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "InitCallback", result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -247,11 +228,11 @@ public class MainActivity extends UnityPlayerActivity {
|
|||
Log.e("SJSDK", "authResult===" + authResult);
|
||||
MainActivity.this.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if (code == 6 && authResult != null &&
|
||||
if (code == CODE_AUTH_TOKEN_SUCCESS && authResult != null &&
|
||||
!authResult.toString().equals("") && authResult.isSuc()) {
|
||||
UnityPlayer.UnitySendMessage("KTSDKHelper", "LoginCallback", String.valueOf(code) + "#" + authResult.getUserID() + "#" + authResult.getToken() + "#" + authResult.getExtension());
|
||||
} else if (code == 7) {
|
||||
UnityPlayer.UnitySendMessage("KTSDKHelper", "LoginCallback", String.valueOf(code) + "#" + "token Error");
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "LoginCallback", SUCCESS + "#" + authResult.getUserID() + "#" + authResult.getToken() + "#" + authResult.getExtension());
|
||||
} else {
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "LoginCallback", FAILED + "#" + "token Error");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -268,6 +249,8 @@ public class MainActivity extends UnityPlayerActivity {
|
|||
}
|
||||
});
|
||||
}
|
||||
public void SwitchLogin() {}
|
||||
public void Logout() {}
|
||||
|
||||
private void logincancel() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder((Context)this);
|
||||
|
@ -287,75 +270,108 @@ public class MainActivity extends UnityPlayerActivity {
|
|||
});
|
||||
AlertDialog alertDialog = builder.create();
|
||||
alertDialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
public void SubmitExtraData(
|
||||
final int dataType,
|
||||
final int serverId,
|
||||
final String serverName,
|
||||
final String zoneID,
|
||||
final String zoneName,
|
||||
final String roleID,
|
||||
final String roleName,
|
||||
final String roleLevel,
|
||||
String guildlD,
|
||||
String Vip,
|
||||
final int moneyNum,
|
||||
final String roleCreateTime,
|
||||
final String roleLevelUpTime) {
|
||||
|
||||
public void SubmitExtraData(final int dataType, final int serverId, final String serverName, final String zoneID, final String zoneName, final String roleID, final String roleName, final String roleLevel, String guildlD, String Vip, final int moneyNum, final String roleCreateTime, final String roleLevelUpTime) {
|
||||
SJSDK.getInstance().runOnMainThread(new Runnable() {
|
||||
public void run() {
|
||||
SJUserExtraData data = new SJUserExtraData();
|
||||
data.setDataType(dataType);
|
||||
data.setMoneyNum(moneyNum);
|
||||
data.setRoleCreateTime(roleCreateTime);
|
||||
data.setRoleID(roleID);
|
||||
data.setRoleName(roleName);
|
||||
data.setRoleLevel(roleLevel);
|
||||
data.setRoleLevelUpTime(roleLevelUpTime);
|
||||
data.setServerID(serverId);
|
||||
data.setServerName(serverName);
|
||||
data.setZoneID(zoneID);
|
||||
data.setZoneName(zoneName);
|
||||
SJUser.getInstance().submitExtraData(data);
|
||||
}
|
||||
public void run() {
|
||||
SJUserExtraData data = new SJUserExtraData();
|
||||
data.setDataType(dataType);
|
||||
data.setMoneyNum(moneyNum);
|
||||
data.setRoleCreateTime(roleCreateTime);
|
||||
data.setRoleID(roleID);
|
||||
data.setRoleName(roleName);
|
||||
data.setRoleLevel(roleLevel);
|
||||
data.setRoleLevelUpTime(roleLevelUpTime);
|
||||
data.setServerID(serverId);
|
||||
data.setServerName(serverName);
|
||||
data.setZoneID(zoneID);
|
||||
data.setZoneName(zoneName);
|
||||
SJUser.getInstance().submitExtraData(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void Pay(
|
||||
final String productId,
|
||||
final String productName,
|
||||
final String productDesc,
|
||||
final int price,
|
||||
final int ratio,
|
||||
final int buyNum,
|
||||
final int coinNum,
|
||||
final String zoneId,
|
||||
final String serverID,
|
||||
final String serverName,
|
||||
String accounted,
|
||||
final String roleID,
|
||||
final String roleName,
|
||||
final int roleLevel,
|
||||
final String vip,
|
||||
final String guildlD,
|
||||
String payNotifyUrl,
|
||||
final String extension) {
|
||||
|
||||
public void Pay(final String productId, final String productName, final String productDesc, final int price, final int ratio, final int buyNum, final int coinNum, final String zoneId, final String serverID, final String serverName, String accounted, final String roleID, final String roleName, final int roleLevel, final String vip, final String guildlD, String payNotifyUrl, final String extension) {
|
||||
SJSDK.getInstance().runOnMainThread(new Runnable() {
|
||||
public void run() {
|
||||
Log.i(MainActivity.this.TAG, "pay time1" + System.currentTimeMillis());
|
||||
MainActivity.this.payParams.setBuyNum(buyNum);
|
||||
MainActivity.this.payParams.setCoinNum(coinNum);
|
||||
MainActivity.this.payParams.setPrice(price);
|
||||
MainActivity.this.payParams.setRatio(ratio);
|
||||
MainActivity.this.payParams.setProductId(productId);
|
||||
MainActivity.this.payParams.setProductName(productName);
|
||||
MainActivity.this.payParams.setProductDesc(productDesc);
|
||||
MainActivity.this.payParams.setRoleId(roleID);
|
||||
MainActivity.this.payParams.setRoleLevel(roleLevel);
|
||||
MainActivity.this.payParams.setRoleName(roleName);
|
||||
MainActivity.this.payParams.setServerId(serverID);
|
||||
MainActivity.this.payParams.setServerName(serverName);
|
||||
MainActivity.this.payParams.setVip(vip);
|
||||
MainActivity.this.payParams.setZoneId(zoneId);
|
||||
MainActivity.this.payParams.setGuildID(guildlD);
|
||||
MainActivity.this.payParams.setExtension(extension);
|
||||
SJPay.getInstance().pay(MainActivity.this.payParams);
|
||||
}
|
||||
public void run() {
|
||||
Log.i(MainActivity.this.TAG, "pay time1" + System.currentTimeMillis());
|
||||
MainActivity.this.payParams.setBuyNum(buyNum);
|
||||
MainActivity.this.payParams.setCoinNum(coinNum);
|
||||
MainActivity.this.payParams.setPrice(price);
|
||||
MainActivity.this.payParams.setRatio(ratio);
|
||||
MainActivity.this.payParams.setProductId(productId);
|
||||
MainActivity.this.payParams.setProductName(productName);
|
||||
MainActivity.this.payParams.setProductDesc(productDesc);
|
||||
MainActivity.this.payParams.setRoleId(roleID);
|
||||
MainActivity.this.payParams.setRoleLevel(roleLevel);
|
||||
MainActivity.this.payParams.setRoleName(roleName);
|
||||
MainActivity.this.payParams.setServerId(serverID);
|
||||
MainActivity.this.payParams.setServerName(serverName);
|
||||
MainActivity.this.payParams.setVip(vip);
|
||||
MainActivity.this.payParams.setZoneId(zoneId);
|
||||
MainActivity.this.payParams.setGuildID(guildlD);
|
||||
MainActivity.this.payParams.setExtension(extension);
|
||||
SJPay.getInstance().pay(MainActivity.this.payParams);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void BackPressed() {
|
||||
public void ExitGame() {
|
||||
SJSDK.getInstance().onBackPressed();
|
||||
SJSDK.getInstance().runOnMainThread(new Runnable() {
|
||||
public void run() {
|
||||
SJUser.getInstance().exit();
|
||||
}
|
||||
public void run() {
|
||||
SJUser.getInstance().exit();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public boolean IsSupportExit() {
|
||||
public boolean IsSupportExit() {
|
||||
return SJUser.getInstance().isSupport("exit");
|
||||
}
|
||||
}
|
||||
|
||||
public String GetIMEICode() {
|
||||
return KTGameDeviceUtil.getIMEI(getBaseContext());
|
||||
}
|
||||
|
||||
public String GetDeviceID() {
|
||||
return KTGameDeviceUtil.getDeviceID(getBaseContext());
|
||||
}
|
||||
|
||||
public String GetOrderID() {
|
||||
public String GetOrderID() {
|
||||
return this.payParams.getOrderID();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void SendScreenshotData(byte[] bytes) {
|
||||
this.bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.mht.tcxcsb.project;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
import com.lingdong.packsdk.plugin.IApplication;
|
||||
|
||||
public class GameApplication implements IApplication {
|
||||
@Override
|
||||
public void onProxyCreate(Application application) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProxyAttachBaseContext(Application application) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProxyConfigurationChanged(Configuration configuration) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTerminate() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,304 @@
|
|||
package com.mht.tcxcsb.project;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import com.bluewhale.jieling.IUnityPlayerActivity;
|
||||
import com.lingdong.packsdk.GameListener;
|
||||
import com.lingdong.packsdk.PSDK;
|
||||
import com.lingdong.packsdk.PSDKPay;
|
||||
import com.lingdong.packsdk.PSDKUser;
|
||||
import com.lingdong.packsdk.bean.MHTManager;
|
||||
import com.lingdong.packsdk.bean.OrderBean;
|
||||
import com.lingdong.packsdk.utils.SDKLogger;
|
||||
import com.unity3d.player.UnityPlayer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MhtActivity extends IUnityPlayerActivity {
|
||||
// private TextView log_tv;
|
||||
|
||||
private String orderId;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
SDKLogger.setDebug(true);
|
||||
PSDK.getInstance().onCreate(this, new GameListener() {
|
||||
@Override
|
||||
public void onInit(int code) {
|
||||
if (code == GameListener.SUCCESS) {
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "InitCallback", MhtActivity.this.SUCCESS);
|
||||
showLog("PSDK初始化成功");
|
||||
} else {
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "InitCallback", MhtActivity.this.FAILED);
|
||||
showLog("PSDK初始化失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLogin(int code, String msg) {
|
||||
if (code == GameListener.SUCCESS) {
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "LoginCallback", MhtActivity.this.SUCCESS + "#" + MHTManager.getuId() + "#" + MHTManager.getToken() + "#" + MHTManager.getUserToken() + "#" + MHTManager.getChannelName());
|
||||
showLog("登录成功:userId:" + MHTManager.getuId() + "\nsessionId:" + MHTManager.getToken() + "\nuserToken: " + MHTManager.getUserToken() + "\nchannelName:" + MHTManager.getChannelName());
|
||||
} else {
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "LoginCallback", MhtActivity.this.FAILED + "#" + msg);
|
||||
showLog("登录失败:" + msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPay(int code, OrderBean callBean) {
|
||||
if (code == GameListener.SUCCESS) {
|
||||
MhtActivity.this.orderId = callBean.getOderId();
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "PayCallback", MhtActivity.this.SUCCESS + "#" + MhtActivity.this.orderId);
|
||||
showLog("支付成功: orderId=" + MhtActivity.this.orderId);
|
||||
} else {
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "PayCallback", MhtActivity.this.FAILED);
|
||||
showLog("支付失败: " + callBean.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLogout(int code) {
|
||||
if (code == GameListener.SUCCESS) {
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "LogoutCallback", MhtActivity.this.SUCCESS);
|
||||
showLog("登出成功");
|
||||
} else {
|
||||
UnityPlayer.UnitySendMessage("SDKManager", "LogoutCallback", MhtActivity.this.FAILED);
|
||||
showLog("登出失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onThirdExit(int code) {
|
||||
if (code == GameListener.SUCCESS) {
|
||||
finish();
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
} else {
|
||||
showLog("退出取消");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit(int code) {
|
||||
if (code == GameListener.SUCCESS) {
|
||||
showLog("退出成功");
|
||||
} else {
|
||||
showLog("退出失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoleSubmit(int code, String msg) {
|
||||
if (code == GameListener.SUCCESS) {
|
||||
showLog(msg);
|
||||
} else {
|
||||
showLog(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
///////////////////////////////重写生命周期方法//////////////////////////////////
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
PSDK.getInstance().onStart(MhtActivity.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
PSDK.getInstance().onPause(MhtActivity.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
PSDK.getInstance().onResume(MhtActivity.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
PSDK.getInstance().onStop(MhtActivity.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
PSDK.getInstance().onDestroy(MhtActivity.this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
PSDK.getInstance().onRestart(MhtActivity.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
PSDK.getInstance().onBackPressed(MhtActivity.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
PSDK.getInstance().onNewIntent(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
PSDK.getInstance().onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
PSDK.getInstance().onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
ExitGame();
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
// 初始化sdk
|
||||
public void Init() {
|
||||
|
||||
}
|
||||
// 调起登录
|
||||
public void Login() {
|
||||
|
||||
PSDKUser.getInstance().login(MhtActivity.this);
|
||||
}
|
||||
public void SwitchLogin() {
|
||||
if (PSDKUser.getInstance().isSupport("switchLogin")) {
|
||||
PSDKUser.getInstance().switchLogin(MhtActivity.this);
|
||||
} else {
|
||||
showLog("平台不支持该接口");
|
||||
}
|
||||
}
|
||||
public void Logout() {
|
||||
if (PSDKUser.getInstance().isSupport("logout")) {
|
||||
PSDKUser.getInstance().logout(MhtActivity.this);
|
||||
} else {
|
||||
showLog("平台不支持该接口");
|
||||
}
|
||||
}
|
||||
|
||||
// 提交数据
|
||||
public void SubmitExtraData(final int dataType,
|
||||
final int serverId,
|
||||
final String serverName,
|
||||
final String zoneID,
|
||||
final String zoneName,
|
||||
final String roleID,
|
||||
final String roleName,
|
||||
final String roleLevel,
|
||||
String guildlD,
|
||||
String Vip,
|
||||
final int moneyNum,
|
||||
final String roleCreateTime,
|
||||
final String roleLevelUpTime) {
|
||||
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
map.put("serverId", String.valueOf(serverId));
|
||||
map.put("serverName", serverName);
|
||||
map.put("roleId", roleID);
|
||||
map.put("roleName", roleName);
|
||||
map.put("roleLevel", roleLevel);
|
||||
map.put("party", guildlD);
|
||||
long time = System.currentTimeMillis() / 1000;
|
||||
map.put("crTime", String.valueOf(time));
|
||||
map.put("ext", "");
|
||||
PSDKUser.getInstance().submitExtraData(MhtActivity.this,map);
|
||||
}
|
||||
|
||||
public void Pay(
|
||||
final String productId,
|
||||
final String productName,
|
||||
final String productDesc,
|
||||
final int price,
|
||||
final int ratio,
|
||||
final int buyNum,
|
||||
final int coinNum,
|
||||
final String zoneId,
|
||||
final String serverID,
|
||||
final String serverName,
|
||||
String accounted,
|
||||
final String roleID,
|
||||
final String roleName,
|
||||
final int roleLevel,
|
||||
final String vip,
|
||||
final String guildlD,
|
||||
String payNotifyUrl,
|
||||
final String extension){
|
||||
|
||||
|
||||
Map<String, String> map2 = new HashMap<>();
|
||||
//必传
|
||||
map2.put("consumerId", roleID);//用户ID
|
||||
map2.put("consumerName", roleName);//玩家昵称
|
||||
map2.put("mhtCurrency", String.valueOf(coinNum));//充值50元宝(数量)
|
||||
map2.put("vipLevel", vip);// vip等级
|
||||
map2.put("playerName",guildlD);// 工会,帮派
|
||||
map2.put("roleName", roleName);// 角色名称
|
||||
map2.put("roleId", roleID);// 角色ID
|
||||
map2.put("roleLevel", String.valueOf(roleLevel));//用户等级
|
||||
///////////////////以下是订单参数////////////////////////
|
||||
map2.put("orderDec", productDesc);//订单描述(必)
|
||||
map2.put("amount", String.valueOf(price));// 购买金额(必)//以分为单位
|
||||
map2.put("balance", "100");// 用户余额
|
||||
map2.put("goodDec", productName);//商品描述
|
||||
map2.put("count", String.valueOf(buyNum));//商品数量
|
||||
map2.put("goodsId", productId);//商品编号(三星必传)
|
||||
map2.put("ext", extension);//透传 传递给sdk sdk传递给后端
|
||||
PSDKPay.getInstance().pay(MhtActivity.this, map2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void ExitGame(){
|
||||
if (PSDKUser.getInstance().isSupport("thirdExit")) {
|
||||
PSDKUser.getInstance().exit(MhtActivity.this);
|
||||
} else {
|
||||
//游戏自己实现退出弹窗
|
||||
new AlertDialog.Builder(this).setMessage("退出游戏?").setPositiveButton("是", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (PSDKUser.getInstance().isSupport("exit")) {
|
||||
PSDKUser.getInstance().exit(MhtActivity.this);
|
||||
}
|
||||
finish();
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
}
|
||||
}).setNegativeButton("否", null).create().show();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean IsSupportExit() {
|
||||
return PSDKUser.getInstance().isSupport("exit");
|
||||
}
|
||||
|
||||
public String GetOrderID() {
|
||||
return this.orderId;
|
||||
}
|
||||
|
||||
public void SendScreenshotData(byte[] bytes) {}
|
||||
|
||||
private void showLog(String log) {
|
||||
System.out.print(log);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ namespace SDK
|
|||
{
|
||||
public class AndroidProxy : Proxy
|
||||
{
|
||||
private static AndroidJavaObject currentActivity;
|
||||
public static AndroidJavaObject currentActivity;
|
||||
|
||||
private const string CLS_UNITY_PLAYER = "com.unity3d.player.UnityPlayer";
|
||||
|
||||
|
@ -79,33 +79,21 @@ namespace SDK
|
|||
{
|
||||
return currentActivity.Call<bool>("IsSupportExit");
|
||||
}
|
||||
//sdk 获取设备标识
|
||||
public override string GetDeviceID()
|
||||
{
|
||||
return currentActivity.Call<string>("GetDeviceID");
|
||||
}
|
||||
//sdk 获取IMEI
|
||||
public override string GetIMEICode()
|
||||
{
|
||||
return currentActivity.Call<string>("GetIMEICode");
|
||||
}
|
||||
//sdk获取支付订单号
|
||||
public override string GetPayOrderID()
|
||||
{
|
||||
return currentActivity.Call<string>("GetOrderID");
|
||||
}
|
||||
|
||||
|
||||
//SDK截屏
|
||||
public override void ShotCapture()
|
||||
public void ShotCapture()
|
||||
{
|
||||
StartCoroutine(ScreenShotPNG());
|
||||
}
|
||||
IEnumerator ScreenShotPNG()
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
//DateTime now = DateTime.Now;
|
||||
//string times = now.ToString("yyyyMMddHHmmss");
|
||||
//string filename = times + ".png";
|
||||
int width = Screen.width;
|
||||
int height = Screen.height;
|
||||
Texture2D screenShot = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
|
@ -114,26 +102,7 @@ namespace SDK
|
|||
byte[] bytes = screenShot.EncodeToPNG();
|
||||
Destroy(screenShot);
|
||||
currentActivity.Call("SendScreenshotData", bytes);
|
||||
//string destination = "/sdcard/DCIM/Capture";
|
||||
//if (!Directory.Exists(destination))
|
||||
//{
|
||||
// Directory.CreateDirectory(destination);
|
||||
//}
|
||||
//string Path_save = destination + "/" + filename;
|
||||
//File.WriteAllBytes(Path_save, bytes);
|
||||
|
||||
//string[] paths = new string[1];
|
||||
//paths[0] = Path_save;
|
||||
//ScanFile(paths);
|
||||
}
|
||||
|
||||
//刷新图片,显示到相册中
|
||||
//void ScanFile(string[] path)
|
||||
//{
|
||||
// using (AndroidJavaObject Conn = new AndroidJavaObject("android.media.MediaScannerConnection", currentActivity, null))
|
||||
// {
|
||||
// Conn.CallStatic("scanFile", currentActivity, path, null, null);
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,9 +40,9 @@ namespace SDK
|
|||
{
|
||||
// 初始化
|
||||
#if UNITY_IOS
|
||||
proxy = this.gameObject.AddComponent<iOS.iOSProxy>();
|
||||
proxy = this.gameObject.AddComponent<iOSProxy>();
|
||||
#elif UNITY_ANDROID
|
||||
proxy = this.gameObject.AddComponent<Android.AndroidProxy>();
|
||||
proxy = this.gameObject.AddComponent<AndroidProxy>();
|
||||
#else
|
||||
proxy = this.gameObject.AddComponent<Proxy>();
|
||||
#endif
|
||||
|
@ -55,25 +55,10 @@ namespace SDK
|
|||
BuglyAgent.InitWithAppId(VersionManager.Instance.GetVersionInfo("buglyId"));
|
||||
BuglyAgent.EnableExceptionHandler();
|
||||
//
|
||||
|
||||
onInitLaunchCallback = InitCallBack;
|
||||
IsInit = true;
|
||||
}
|
||||
|
||||
|
||||
public void SetInitCallBack(InitLaunchAction action)
|
||||
{
|
||||
onInitLaunchCallback += action;
|
||||
}
|
||||
|
||||
private void InitCallBack(string data)
|
||||
{
|
||||
string[] strArray = data.Split('#');
|
||||
string code = strArray[0];
|
||||
string result = strArray[1];
|
||||
Debug.LogFormat("InitResult>>code:{0},result:{1}", code, result);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
var msg = proxy.PopMessage();
|
||||
|
|
|
@ -400,7 +400,7 @@ namespace GameEditor.FrameTool
|
|||
{
|
||||
if (string.IsNullOrEmpty(paths[i].Path))
|
||||
{
|
||||
Debug.LogErrorFormat("MarkGame error:BuildConfigs contain null floder.");
|
||||
Debug.LogErrorFormat("MarkGame error:BuildConfigs contain null floder." + paths[i].Path);
|
||||
continue;
|
||||
}
|
||||
AssetBundleBuilder.MarkOneFloderOneBundle(paths[i].Path, paths[i].CompressType);
|
||||
|
|
|
@ -36,9 +36,9 @@ public class GameStart : MonoBehaviour
|
|||
if (AppConst.isSDK && !SDK.SDKManager.Instance.IsInit) //当登录sdk时,等待初始化完成后再走闪屏流程
|
||||
{
|
||||
SDK.SDKManager.Instance.Initialize();
|
||||
SDK.SDKManager.Instance.SetInitCallBack(s => {
|
||||
SDK.SDKManager.Instance.onInitLaunchCallback += s => {
|
||||
playSplash();
|
||||
});
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue