Skip to content

Commit 0117dd5

Browse files
authored
Merge pull request #637 from rh101/fix-screen-blank
Fix Android screen blank issue after unlocking device
2 parents 6943fb9 + 3a3b899 commit 0117dd5

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

core/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,9 @@ protected void onResume() {
171171
Log.d(TAG, "onResume()");
172172
paused = false;
173173
super.onResume();
174-
this.hideVirtualButton();
175-
resumeIfHasFocus();
174+
if (this.hasFocus) {
175+
resume();
176+
}
176177
}
177178

178179
@Override
@@ -181,7 +182,15 @@ public void onWindowFocusChanged(boolean hasFocus) {
181182
super.onWindowFocusChanged(hasFocus);
182183

183184
this.hasFocus = hasFocus;
184-
resumeIfHasFocus();
185+
if (this.hasFocus && !paused) {
186+
resume();
187+
}
188+
}
189+
190+
private void resume() {
191+
this.hideVirtualButton();
192+
Cocos2dxHelper.onResume();
193+
mGLSurfaceView.onResume();
185194
}
186195

187196
private void resumeIfHasFocus() {
@@ -190,9 +199,7 @@ private void resumeIfHasFocus() {
190199
boolean readyToPlay = !isDeviceLocked() && !isDeviceAsleep();
191200

192201
if(hasFocus && readyToPlay) {
193-
this.hideVirtualButton();
194-
Cocos2dxHelper.onResume();
195-
mGLSurfaceView.onResume();
202+
resume();
196203
}
197204
}
198205

0 commit comments

Comments
 (0)