In older versions of Android, it was necessary to use: android:theme="#android:style/Theme.NoTitleBar.Fullscreen" in the manifest to make the title bar disappear.
In the newer ADT versions, I have noticed a SystemUiHider class, which lets you make calls to it's hide() method to remove not only the title bar, but also the action bar and navigation bar.
I am trying to write a fullscreen app, that I would like to stay full screen (for a kiosk implementation), unless a small hidden button is pressed.
I've tried taking the standard FullscreenActivity (generated from the new android project wizard), and prevent the UI from reappearing in a number of ways:
Making calls to mSystemUiHider.hide() in the setOnVisibilityChangeListener (to try and immediately hide the UI when it detects a change in visibility)
Setting: AUTO_HIDE_DELAY_MILLIS = 0 (to try and immediately hide it if it is visible)
Preventing the call to mSystemUiHider.show(); within the onClick method of the contentView.setOnClickListener (to prevent it from being shown)
I have also seen the setSystemUiVisibility example in the docs for android.view (again to try and hide it immediately if shown or visibility is changed)
None of them seem to work (Android defaults to the Low Profile Mode for the Navigation Bar when any of these are tried.
I understand that they probably don't want developers doing what I'm trying to do, but I was hoping that I could extend SystemUiHider (and/or SystemUiHiderBase) and override the show() methods to essentially not show unless passed a true flag. I can't seem to find any documentation on either of these classes (perhaps because they're utility classes?).
Any interaction with the device brings back the navigation bar.
https://developer.android.com/reference/android/view/View.html#SYSTEM_UI_FLAG_HIDE_NAVIGATION
Related
I'm currently working on an app for blind people. What I need is to prevent users from accidentally going outside of my app, so I'm trying to overlay/replace/hide soft buttons in Android 4. I know this must be possible because it is used for example in MXPlayer (you can "lock" screen when playing video).
I've tried to override all three buttons (back,home,recent apps). No problem with back and home, but I couldn't figure out how to override(disable) recent apps. I've tried solution described here without success.
Next idea was to overlay the entire screen. I've successfully created system overlay mentioned in this question, but I didn't find out how to overlay my soft buttons.
Do you have any idea how to solve this problem without rooting the phone and using custom ROM?
edit: I've also tried hiding the buttons with SYSTEM_UI_FLAG_LOW_PROFILE(turns buttons into dots) and SYSTEM_UI_FLAG_HIDE_NAVIGATION(hides buttons till next touch). Unfortunately this also doesn't solve my problem because after touch buttons work as usual. Maybe there's a way how to catch "unhiding" a override showing them again?
From Android docs :
The SYSTEM_UI_FLAG_LOW_PROFILE flag replaces the STATUS_BAR_HIDDEN flag. When set, this flag enables “low profile" mode for the system bar or navigation bar. Navigation buttons dim and other elements in the system bar also hide. Enabling this is useful for creating more immersive games without distraction for the system navigation buttons.
The SYSTEM_UI_FLAG_VISIBLE flag replaces the STATUS_BAR_VISIBLE flag to request the system bar or navigation bar be visible.
The SYSTEM_UI_FLAG_HIDE_NAVIGATION is a new flag that requests the navigation bar hide completely. Be aware that this works only for the navigation bar used by some handsets (it does not hide the system bar on tablets). The navigation bar returns to view as soon as the system receives user input. As such, this mode is useful primarily for video playback or other cases in which the whole screen is needed but user input is not required.
I am developing a magazine reader application aimed at the Kindle Fire. In landscape mode the built in softkey bar and status bar in the Kindle's operating system leave little room for my content so I have opted to run the activity in fullscreen mode using the following theme for the activity:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
This works fine, the status bar is hidden and the softbar is minimized like so:
I can bring up the menu bar by dragging it up like so:
The bug arises when I then click somewhere on screen to dismiss the softkey bar. The bottom bar slides back away, the top one does too but the space that it took up becomes a black void and my app is pushed down underneath it so my tab bar at the bottom of the app is now unusable:
I am using a tabhost activity here and the tab I am on in these screenshots is the actual reader section of the app. This subactivity uses a PDF viewer widget which is written using native code and this bug only happens on this tab. If I switch to one of the other tabs which contain no JNI code this bug does not happen so I'm pretty sure its the combination of the Kindle Fire OS, the fullscreen activity and the use of JNI code.
Has anyone else experience this issue?
Any help much appreciated!
Thanks
There are a couple of fullscreen modes for the Fire (at least the new ICS based ones) - check out https://developer.amazon.com/sdk/fire/cx-guidelines.html#Fullscreen for the options. I suspect the ICS Full Screen mode will be what you need
Also it's probably worth trapping the onOrientationChanged and onSizeChanged events to make sure you re-draw the screen correctly when the menu/toolbars appear and disappear per the screen layout sample at https://developer.amazon.com/sdk/fire/samples.html
i want make Fullscreen in android 4.0, i use android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
the action bar is disappear, but the status bar isn't appear
i use
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
before "setContentView()"
OK, FullScreen!! however, when the dialog or popupwindow show, the status bar appear again,
i read the source code and find the word :
There is a limitation: because navigation controls are so important,
the least user interaction will cause them to reappear immediately.
can i make fullscreen anytime? help me!
There is a limitation: because navigation controls are so important, the least user * interaction will cause them to reappear immediately.
In other words, Android is telling you that the limitation exists because it would be a bad idea to prevent the user from accessing the navigation controls. Doing so would surely disrupt the user experience and would probably piss off a lot of users. That said, unless you have a very good reason for doing so, you should leave it the way it is.
For the Xperia Play prior to ICS, the only way to get input from the touchpad is through a NativeActivity (not a plain old Activity). Unfortunately, all drawing in a NativeActivity, as the name suggests, is done on the native-side, not Java-side. In order to get input on the native-side with graphics on the Java-side, the following must be added to the NativeActivity's onCreate method:
getWindow().takeSurface( null );
getWindow().setContentView( R.layout.main );
And set up a couple methods through JNI for receiving the touchpad and touchscreen input from the native-side. You can then happily draw through Android's Java API, while still getting the touchpad input. This works quite well for Xperia Play's running pre-ICS. Even adding menus via onCreateOptionsMenu doesn't cause any problem.
The problem comes when the Xperia Play is running ICS. The menu has moved to the Action Bar. Unfortunately, it isn't possible to interact with the action bar (pressing the 3 dots is ignored, and it acts like I'm pressing the surface behind the action bar.)
In case it makes any difference, I am creating the action bar menu options through onCreateOptionsMenu. I am using Window.FEATURE_ACTION_BAR_OVERLAY, and making the actionbar visible like so when the user presses the "back" button (mSingleton is the NativeActivity instance):
mSingleton.runOnUiThread(
new Runnable()
{
public void run()
{
if( mSingleton.getActionBar().isShowing() )
mSingleton.getActionBar().hide();
else
mSingleton.getActionBar().show();
}
} );
This makes the action bar visible, but as I mentioned, I can't interact with it. Is there a way to force the action bar to have focus or something? The fact that normal menus work fine on pre-ICS versions makes me think it should be possible to interact with the action bar too, since it is just a menu of a different type.
The Android app Thrutu puts a drawer on top of the in call screen which has several functions and only takes up a fraction of the screen. The call control buttons below still are fully functional. Even a transparent activity would not allow this behaviour. Any idea on how to implement this?
The trick to making the underlying buttons work is to implement the UI using a Service rather than an Activity, make the Window you add (using WindowManager.addView) one of the higher-priority types (e.g. TYPE_PHONE), then use FLAG_NOT_TOUCH_MODAL.
I think you need android.permission.SYSTEM_ALERT_WINDOW.
Take a look at How to display a fullscreen TYPE_SYSTEM_ALERT window? and in particular Creating a system overlay where the home buttons still work?