Im developing an android application for a school and i want this application when opened to prevent the user from doing anything on the device except what im offering inside my application, and i mean doing NOTHING else...
so first the Navigation bar should be disabled and hided
i saw this but its for 4.4+ and it doesn't solve the problem because if you swipe the screen you will get the menu back.
(How to hide navigation bar permanently in android activity?)
this doesn't work also(Permanently hide navigation bar on activity) (Is there a way to hide the system/navigation bar in Android ICS)
i also tried to disable navigation bar actions using onKeyDown but it didn't work on all of the keys.
in addition i want to remove the notification bar which make the user access the settings of the device and other things..
and this not working also (Disable the notification panel from being pulled down) as mentioned in this link it doesn't solve it, it just hides it after showing it :S
help would be appreciated,
Thanks.
You can get a kiosk type mode in Android 5.0, using the screen pinning feature mentioned here:
Android 5.0 introduces a new screen pinning API that lets you
temporarily restrict users from leaving your task or being interrupted
by notifications. This could be used, for example, if you are
developing an education app to support high stakes assessment
requirements on Android, or a single-purpose or kiosk application.
Once your app activates screen pinning, users cannot see
notifications, access other apps, or return to the home screen, until
your app exits the mode.
You can lock the device down to be a kiosk. The navigation bar is not hidden, but the home and recents buttons can be removed or disabled depending how you activate the mode. I wrote some information after testing this feature here.
Its possible
To disable the Status NotificationBar:
You need to place a view on top of the notification bar, so that we hijack the touch events to the Status notification bar. Without further ado, here is the code:
mView= new TextView(this);
mView.setText(".........................................................................");
mLP = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
100,
// Allows the view to be on top of the StatusBar
WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
// Keeps the button presses from going to the background window
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
// Enables the notification to recieve touch events
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
// Draws over status bar
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
mLP.gravity = Gravity.TOP|Gravity.CENTER;
mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
mWindowManager.addView(mView, mLP);
And since you are using the system overlay window, you need the permission:
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
Note:
Do not make your app full screen, as the versions above 17, which supports immersive mode, will screw this approach.
You can NOT disable the system or notification panel in Android.
You can hide these elements (like you have already discovered), but currently, you can NOT disable them permanently.
You are looking for a 'Kiosk Mode' which is not supported.
The closest thing to what you are looking for is 'Immersive Mode' (details) - but this does NOT hide the settings or navigation controls permanently.
Related
Some background information:
My app will be used by guests at an event to perform self check-ins. They should not be able to navigate away from the page, access the device's settings, etc. This means that it has to enter a Kiosk Mode of sorts.
I need to disable the notifications tray completely, meaning even if the user swipes downward from the top of the screen, the status bar should not appear. It's the one which shows your battery life, WiFi/3G connection, etc.
I have already made my application fullscreen, which hides the status bar, but somehow the status bar still appears once the user swipes downward from the top of the screen. Performing another swipe will subsequently open the notifications tray.
My device runs on Jelly Bean, but is aimed to cater to devices as old as Ice Cream Sandwich.
How should I go about disabling the notifications tray? Is there code that can help me, or is it as simple as advising the user to disable some settings of some sort (like how the iPad can simply disable gestures in the device's settings)?
Thanks in advance,
Rei
Take a look at this.
View disableStatusBar = new View(context);
WindowManager.LayoutParams handleParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.FILL_PARENT,
<height of the status bar>,
// This allows the view to be displayed over the status bar
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
// this is to keep button presses going to the background window
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
// this is to enable the notification to recieve touch events
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
// Draws over status bar
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
handleParams.gravity = Gravity.TOP;
context.getWindow().addView(view, handleParams);
Hello,
I need do fullscreen in android 4.0 (I must hide back button, home...)
I used android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
but it doesn't work.
Homebutton and backbutton cannot be hidden...
Users always need to have access to these buttons, so the black bar will always be on the screen
Like write K_Anas in a relative question, it is not possible hide Homebutton and backbutton in Android 4.0, for security reasons and because is a simply anti-pattern solution.
You can use SYSTEM_UI_FLAG_HIDE_NAVIGATION to hide the system navigation temporarily, but it will always reappear when the user touches the screen. Even the notification bar will reappear when the screen is touched.
You are not allowed to hide the system bar with the home button completely for security reasons.
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.
In my video play app, I use this flag: SYSTEM_UI_FLAG_HIDE_NAVIGATION to make the navigation bar disappear, but when I touch the screen, the navigation bar appears, after the first touch, my touch events and other events work fine.
My question is how can I take over the first touch?
You can't really take over the first event. You could implement View.OnSystemUiVisibilityChangeListener and be notified when the navigation bar is shown or hidden again, and then depending on its current state do what you wanted on the first touch, if possible.
However, there is no way you can completely take over the first touch, as stated in the documentation for SYSTEM_UI_FLAG_HIDE_NAVIGATION:
There is a limitation: because navigation controls are so important, the least user interaction will cause them to reappear immediately. When this happens, both this flag and SYSTEM_UI_FLAG_FULLSCREEN will be cleared automatically, so that both elements reappear at the same time.
For anyone coming across this post, if your intention is to hide the navigation/status bar and not have it come back up when you touch the screen, take a look at the different "immersive" configurations as described here: https://developer.android.com/training/system-ui/immersive
for example:
currentActivity?.window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or
View.SYSTEM_UI_FLAG_FULLSCREEN or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
That would effectively put your screen in "Full Screen" Mode regardless of any interaction the user has with the screen
To show the navigation/status bar again, simply change it back to:
currentActivity?.window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE
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