From 3f7c41c05c83cd7671969eec01e9561a8ebf8f37 Mon Sep 17 00:00:00 2001 From: White Dragon <000whitedragon000@gmail.com> Date: Sun, 25 Feb 2018 04:18:45 +0100 Subject: [PATCH] better code for SDLActivity.java --- engine/android/src/org/libsdl/app/SDLActivity.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/engine/android/src/org/libsdl/app/SDLActivity.java b/engine/android/src/org/libsdl/app/SDLActivity.java index 1c81812de..332d84386 100644 --- a/engine/android/src/org/libsdl/app/SDLActivity.java +++ b/engine/android/src/org/libsdl/app/SDLActivity.java @@ -195,13 +195,13 @@ protected void onDestroy() { SDLActivity.nativeQuit(); // Now wait for the SDL thread to quit - if (mSDLThread != null) { + if (SDLActivity.mSDLThread != null) { try { - mSDLThread.join(); + SDLActivity.mSDLThread.join(); } catch(Exception e) { Log.v("SDL", "Problem stopping thread: " + e); } - mSDLThread = null; + SDLActivity.mSDLThread = null; //Log.v("SDL", "Finished waiting for SDL thread"); } @@ -558,7 +558,7 @@ public void surfaceDestroyed(SurfaceHolder holder) { Log.v("SDL", "surfaceDestroyed()"); // Call this *before* setting mIsSurfaceReady to 'false' if (SDLActivity.wakeLock.isHeld()) SDLActivity.wakeLock.release(); - //SDLActivity.handlePause(); + SDLActivity.handlePause(); SDLActivity.mIsSurfaceReady = false; SDLActivity.onNativeSurfaceDestroyed(); } @@ -623,7 +623,6 @@ public void surfaceChanged(SurfaceHolder holder, SDLActivity.mIsSurfaceReady = true; SDLActivity.onNativeSurfaceChanged(); - if (SDLActivity.mSDLThread == null) { // This is the entry point to the C app. // Start up the C app thread and enable sensor input for the first time @@ -631,6 +630,9 @@ public void surfaceChanged(SurfaceHolder holder, SDLActivity.mSDLThread = new Thread(new SDLMain(), "SDLThread"); enableSensor(Sensor.TYPE_ACCELEROMETER, false); SDLActivity.mSDLThread.start(); + } else { + if (!SDLActivity.wakeLock.isHeld()) SDLActivity.wakeLock.acquire(); + SDLActivity.handleResume(); } }