diff --git a/cocos/platform/android/java/project.properties b/cocos/platform/android/java/project.properties index 88ca83f9d0..f2c8b26db8 100644 --- a/cocos/platform/android/java/project.properties +++ b/cocos/platform/android/java/project.properties @@ -12,4 +12,4 @@ android.library=true # Project target. -target=android-10 +target=android-21 diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java index 9981f9b8c0..cfe8c8bf98 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java @@ -39,6 +39,7 @@ import android.preference.PreferenceManager.OnActivityResultListener; import android.util.AttributeSet; import android.util.Log; import android.view.ViewGroup; +import android.view.View; import android.view.Window; import android.view.WindowManager; import android.widget.FrameLayout; @@ -258,6 +259,8 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); + this.hideVirtualButton(); + onLoadNativeLibraries(); sContext = this; @@ -301,6 +304,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe protected void onResume() { Log.d(TAG, "onResume()"); super.onResume(); + this.hideVirtualButton(); resumeIfHasFocus(); } @@ -308,6 +312,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe public void onWindowFocusChanged(boolean hasFocus) { Log.d(TAG, "onWindowFocusChanged() hasFocus=" + hasFocus); super.onWindowFocusChanged(hasFocus); + this.hideVirtualButton(); this.hasFocus = hasFocus; resumeIfHasFocus(); @@ -411,6 +416,20 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe return glSurfaceView; } + protected void hideVirtualButton() { + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + + getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar + | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar + | View.SYSTEM_UI_FLAG_IMMERSIVE); + } + } + private final static boolean isAndroidEmulator() { String model = Build.MODEL; Log.d(TAG, "model=" + model);