[Android] Fixes #2679 - Crash resuming from screen off
authorGabriel Jacobo <gabomdq@gmail.com>
Wed, 17 Sep 2014 08:59:43 -0300
changeset 9144c197a316685a
parent 9143 b664273a455c
child 9145 aa99e029b12e
[Android] Fixes #2679 - Crash resuming from screen off

Before destroying the static Java-side data, wait for the SDL native thread,
*and* the listener thread that waits on it to trigger a clean up.
android-project/src/org/libsdl/app/SDLActivity.java
     1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Tue Sep 16 23:09:32 2014 +0200
     1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Wed Sep 17 08:59:43 2014 -0300
     1.3 @@ -932,16 +932,16 @@
     1.4              // This is the entry point to the C app.
     1.5              // Start up the C app thread and enable sensor input for the first time
     1.6  
     1.7 -            SDLActivity.mSDLThread = new Thread(new SDLMain(), "SDLThread");
     1.8 +            final Thread sdlThread = new Thread(new SDLMain(), "SDLThread");
     1.9              enableSensor(Sensor.TYPE_ACCELEROMETER, true);
    1.10 -            SDLActivity.mSDLThread.start();
    1.11 +            sdlThread.start();
    1.12              
    1.13              // Set up a listener thread to catch when the native thread ends
    1.14 -            new Thread(new Runnable(){
    1.15 +            SDLActivity.mSDLThread = new Thread(new Runnable(){
    1.16                  @Override
    1.17                  public void run(){
    1.18                      try {
    1.19 -                        SDLActivity.mSDLThread.join();
    1.20 +                        sdlThread.join();
    1.21                      }
    1.22                      catch(Exception e){}
    1.23                      finally{ 
    1.24 @@ -951,7 +951,8 @@
    1.25                          }
    1.26                      }
    1.27                  }
    1.28 -            }).start();
    1.29 +            });
    1.30 +            SDLActivity.mSDLThread.start();
    1.31          }
    1.32      }
    1.33