| | |
| | | package com.secondworld.sdk; |
| | | |
| | | import android.app.AlarmManager; |
| | | import android.app.Application; |
| | | import android.app.PendingIntent; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.pm.PackageManager; |
| | | import android.os.Handler; |
| | |
| | | import com.secondworld.sdk.utils.LogUtil; |
| | | import com.unity3d.player.UnityPlayer; |
| | | |
| | | public class GameApp extends Application { |
| | | public abstract class GameApp extends Application { |
| | | |
| | | public static GameApp I; |
| | | |
| | | public String appId = ""; |
| | | |
| | | protected boolean isDemo = false; |
| | | |
| | | @Override |
| | | public void onCreate() { |
| | | super.onCreate(); |
| | | I = this; |
| | | InitSdk(); |
| | | } |
| | | |
| | | public void InitSdk() { |
| | | newInstance(); |
| | | initPlatformDiff(); |
| | | LogUtil.Init(this); |
| | | UnityMsgHandler.initCommandMap(); |
| | | registerProxy(); |
| | | initSdk(); |
| | | } |
| | | |
| | | public static void AppExit() { |
| | | protected void newInstance() { |
| | | I = this; |
| | | } |
| | | |
| | | protected abstract void initPlatformDiff(); |
| | | |
| | | protected void registerProxy() { |
| | | |
| | | } |
| | | |
| | | protected void initSdk() { |
| | | } |
| | | |
| | | public void appExit() { |
| | | new Handler().postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | |
| | | UnityPlayer.currentActivity.finish(); |
| | | } |
| | | |
| | | public static void RestartApp() { |
| | | public void restartApp() { |
| | | new Handler().postDelayed(() -> { |
| | | String _pn = I.getPackageName(); |
| | | PackageManager packageManager = I.getPackageManager(); |
| | | Intent intent = packageManager.getLaunchIntentForPackage(_pn); |
| | | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| | | I.startActivity(intent); |
| | | android.os.Process.killProcess(android.os.Process.myPid());// 杀进程 |
| | | String _pn = I.getPackageName(); |
| | | PackageManager packageManager = I.getPackageManager(); |
| | | Intent intent = packageManager.getLaunchIntentForPackage(_pn); |
| | | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| | | I.startActivity(intent); |
| | | android.os.Process.killProcess(android.os.Process.myPid());// 杀进程 |
| | | }, 1000); |
| | | if (UnityPlayer.currentActivity != null) |
| | | UnityPlayer.currentActivity.finish(); |
| | | } |
| | | |
| | | //是否位demo |
| | | public boolean isDemo() { |
| | | return isDemo; |
| | | } |
| | | |
| | | } |