Improve handling of focus behaviour on Android. Patch by Alexey Petruchik
authorGabriel Jacobo <gabomdq@gmail.com>
Sat, 10 May 2014 18:24:39 -0300
changeset 8768 a9520d7a579c
parent 8767 8719af30db6b
child 8769 27789b1ac26d
Improve handling of focus behaviour on Android. Patch by Alexey Petruchik
android-project/src/org/libsdl/app/SDLActivity.java
--- a/android-project/src/org/libsdl/app/SDLActivity.java	Sat May 10 17:00:37 2014 -0300
+++ b/android-project/src/org/libsdl/app/SDLActivity.java	Sat May 10 18:24:39 2014 -0300
@@ -190,7 +190,7 @@
         if (SDLActivity.mIsPaused && SDLActivity.mIsSurfaceReady && SDLActivity.mHasFocus) {
             SDLActivity.mIsPaused = false;
             SDLActivity.nativeResume();
-            mSurface.enableSensor(Sensor.TYPE_ACCELEROMETER, true);
+            mSurface.handleResume();
         }
     }
         
@@ -550,6 +550,15 @@
         mWidth = 1.0f;
         mHeight = 1.0f;
     }
+     
+    public void handleResume() {
+        setFocusable(true);
+        setFocusableInTouchMode(true);
+        requestFocus();
+        setOnKeyListener(this);
+        setOnTouchListener(this);
+        enableSensor(Sensor.TYPE_ACCELEROMETER, true);
+    }
     
     public Surface getNativeSurface() {
         return getHolder().getSurface();