I'm making an slideshow app for device running Android. I want to disable notification shade and soft buttons swipe to prevent customers from accessing OS. I know that i can use TYPE_SYSTEM_OVERLAY flag, but it disables touch events, so this is not a solution. Is there are way to achieve what i want? Thanks!
Dedicated devices that should "disable notifications shade and soft buttons" aka kiosk mode, should use screen pinning or task locking. For information about implementation of kiosk mode read Dedicated devices overview and DevicePolicyManager.
Related
Both Android and iPhone:
With a screen overlay, can it be used to activate parts of the screen, thereby simulating user actions, activating the underlying action areas on the screen, i.e. scrolling?
I found this floating window library but that may do the trick on Android, wondering if anyone else has suggestions?
With a screen overlay, can it be used to activate parts of the screen, thereby simulating user actions, activating the underlying action areas on the screen, i.e. scrolling?
No, on Android. Faking input into other apps has significant security ramifications. On Android, accessibility services have some limited ability to do this sort of thing, which is why Google is starting to restrict their distribution. And, of course, on a rooted device you will have more options.
As it's said in android developers blog:
By itself, the touch mode is something very easy to understand as it simply indicates whether the last user interaction was performed with the touch screen. For example, if you are using a G1 phone, selecting a widget with the trackball will take you out of touch mode; however, if you touch a button on the screen with your finger, you will enter touch mode. When the user is not in touch mode, we talk about the trackball mode, navigation mode or keyboard navigation...
But android is booting by default in touch mode. How can I switch device into keyboard navigation mode, or make it a default one?
I'm developing app for a specific device, so it's rooted and I can also modify firmware.
You can force an Android device in or out of touch mode using Instrumentation.setInTouchMode(boolean).
new Instrumentation().setInTouchMode(false);
Running this as part of a boot receiver would probably achieve what you are looking for.
I was using startLockTask() in a program but found out it could only be used for Android L. However I want my application to function in versions lower then 5.
Is there any way I can gain similar functionality?
Functionally, no. The point of screen pinning is to prevent the user from leaving your app. The user can't see or click on notifications, or use the home button to leave.
Visually, you can set the app to full screen,, and/or hide notification bar. You can also hide the soft keys on devices that don't have hardware buttons. However, people can always bring it back up.
EDIT: You can also disable the back button.
I have found non rooted apps which are capable of hide home button from bottom system bar of tabs (not all the devices but many of samsung tabs) & disabling (not hiding) right side wifi, settings entering panel in system bar (worked in all the testing devices). Good example is remote lock screen of Lookout premium app with BIND_DEVICE_ADMIN permission. This lock screen appears on top of the native android lock screen it has these features work in many devices.
Is there a way to create an activity with disabling System bar like that? Is it related to the flag that adding to the layout params of the activity? Otherwise how this is implemented?
Thanks.
A few users have been asking me Android lock screen widgets for my app - I believe they want a widget that stays on their lock screens and allows them to interact with the app.
I haven't been able to find any official documentation for this - the only thing I found was apps that will take home screen widgets and put them on the lock screen for you.
Any clues on where I learn more about building true lock-screen widgets?
Lock screen interaction is difficult. Android allows basic operations with two window flags (FLAG_SHOW_WHEN_LOCKED and FLAG_DISMISS_KEYGUARD). FLAG_SHOW_WHEN_LOCKED works pretty consistently in that it will show on top of the lock screen even when security is enabled (the security isn't bypassed, you can't switch to another non-FLAG_SHOW_WHEN_LOCKED window).
If you're just doing something temporary, like while music is playing or similar, you'll probably mostly be okay. If you're trying to create a custom lock screen then there's a lot of unusual interactions on all the different android platforms. ("Help! I can't turn off my alarm without rebooting my HTC phone").
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html
FLAG_SHOW_WHEN_LOCKED
Window flag: special flag to let windows be shown when the screen is
locked.
FLAG_DISMISS_KEYGUARD
Window flag:
when set the window will cause the keyguard to be
dismissed, only if it is not a secure
lock keyguard. Because such a keyguard
is not needed for security, it will
never re-appear if the user navigates
to another window (in contrast to
FLAG_SHOW_WHEN_LOCKED, which will only
temporarily hide both secure and
non-secure keyguards but ensure they
reappear when the user moves to
another UI that doesn't hide them). If
the keyguard is currently active and
is secure (requires an unlock pattern)
than the user will still need to
confirm it before seeing this window,
unless FLAG_SHOW_WHEN_LOCKED has also
been set.
Constant Value: 4194304 (0x00400000)
Official Lock screen widget document is here
I had to implement a lock screen widget for my project. In the process, I accumulated a couple of resources.
If you have an app that you want to put on the lock screen, first make it an appwidget. You can use the AppWidget class to do this.
Now, use the AppWidgetHost class from the Android API to make your lock screen a host for the widgets. I don't know how to do this part, but there are some existing implementations like mylockandroid (links below).
Resources
http://code.google.com/p/mylockforandroid/
(NB This code is for older versions of Android. Android 4.2 and up has built in lockscreen widget support)
http://mylockandroid.blogspot.com/2010/03/widget-lockscreen-beta-11-r2.html