-
abhishekLikes 0Problem Description
Hi Sonar Systems,
I am sorry if this seems like a noob question, but please help me out with this.
I have developed my game using cocos2d-x and C++ using Xcode.
I then ported the game to Android using the python command and everything is working correctly on Android.
But now, how can i hide the software keys of Android devices like Nexus 5 etc.?
I dont want user to see those soft keys, its even ok if that area is hidden and becomes a part of the game UI.
I did search on the internet and have seen people suggesting code like this:
But where exactly do i have to write this code?public void FullScreencall() { if(Build.VERSION.SDK_INT < 19) //19 or above api View v = this.getWindow().getDecorView(); v.setSystemUiVisibility(View.GONE); } else { //for lower api versions. View decorView = getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; decorView.setSystemUiVisibility(uiOptions); } }
-
Sonar Systems adminLikes 0
Check this link out https://developer.android.com/training/system-ui/immersive.html
-
abhishekLikes 0
hi..
i have already tried the above link..
there are two problems i faced:
1 – this works only for android 4.4 and above
2 – i tried it, but in eclipse, the SYSTEM_UI_FLAG_IMMERSIVE and SYSTEM_UI_FLAG_IMMERSIVE_STICKY give an arror (cannot be resolved or is not a field)
and its okay if the soft keys are not completely hidden..
in some games, those soft keys turn into dots and when you tap on the keys, they turn back into the actual keys
is there any simple way to do this?
ALSO, this much part of the code works
when the game starts, the nav keys are hidden
BUT as soon as i tap on the screen, the nav bar (soft keys) come back
so this also doesnt do anything
Can you please help?
ThanksglSurfaceView.setSystemUiVisibility(
Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_LAYOUT_STABLE
| Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
UPDATE:
I managed to get some progress. I added a new line and commented 2 lines. With this, I am now getting dots in place of the soft key. But once i tap on the nav bar, the original keys come up and then they dont turn back into dots again. So what should i do in order to change them back to dots if user does not want to interact with them.glSurfaceView.setSystemUiVisibility(
Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_LAYOUT_STABLE
| Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION (COMMENTED THIS LINE)
| Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar (COMMENTED THIS LINE)
| Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_LOW_PROFILE); (ADDED THIS LINE)
-
Sonar Systems adminLikes 0
Personally I wouldn’t bother because we used to do this but many Android users moaned as they preferred having the buttons on.
-
abhishekLikes 0
Hi SS,
Recently i implemented AdMob in my cocos2dx C++ project for Andoid using one of your tutorials.
Everything works fine, but I have a request for an added feature as and when you have time.
In your tutorial, you ask us to overwrite the AppActivity.java file, which now extends SonarFramework instead of Cocos2dxActivity
So can you make a tutorial in which you show us how to hide the soft keys (show black patch with white dots) or implement immersive mode?
I understand that this does not affect the game so much, but in many games this is required.. so it would be great if you could help us out with this.
Thanks a lot.
:)This reply has been verified.
-
Sonar Systems adminLikes 0
Hello abhishek,
Android Immersive mode is on our list of tasks to do for the Cocos Helper, check out the upcoming features at https://github.com/SonarSystems/Cocos-Helper
But what do you mean by many games this is required?
-
abhishekLikes 0
Thank you so much for adding Immersive Mode to your list.. Can you please push it to the top a little.. and may be a little more towards the top :)
I said that Immsersive mode is required in many games because i mainly focus on learning and educational games for kids.
And whenever i tested the app with kids using android devices, the kids would end up tapping on one of the soft keys by mistake.
And they would exit from the app or go into the recent apps menu etc.
So for me, in order to provide a safe and easy to use environment for kids, immersive mode is very helpful.
Thanks
:)
-
Sonar Systems adminLikes 0
The list is in no particular order.
That makes sense :D
Login to reply