Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an app unclosable?

Tags:

java

android

After a user opens my application I don't want them to be able to get out. So when they press the home or back button it doesn't let them exit the app. I know there are ways using a service to keep the app always running in the background, but I don't even want them to even exit.

Is this even possible, if so how? Without having to hack the kernel.

I know this sounds odd, but it is not for a commercial app, but for my lab, it will never be on GooglePlay. The tablets will be given to little kids and they will take a test on it, so I can't have them using youtube or anything else.


Related post: Android, How to make the task of the app unclosable? Only closable by task killing

The answer by CommonWare seems to indicate that kernel hacking is the only way, but is it?

Also I am using Android L.

like image 742
J_Strauton Avatar asked Nov 24 '25 15:11

J_Strauton


1 Answers

there is no official support yet - there will be support with android L via the Task locking API

The L Developer Preview introduces a new task locking API that lets you temporarily restrict users from leaving your app 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. Once your app activates this mode, users will not be able to see notifications, access other apps, or return to the Home screen, until your app exits the mode.

https://developer.android.com/preview/api-overview.html

EDIT: as you said you use L this got obsolete - but I leave it here as a hint for others

said that - you are also able to get this kind of work without root today if you have to ( e.g. kiosk mode app on a certain hardware ). It is not simple - and no solution that works for all devices - but if you need it you can get it work with tricks like: - reacting on home-screen intent ( and setting it as default ) - when you go to background - bring your self foreground again - ..

like image 103
ligi Avatar answered Nov 27 '25 05:11

ligi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!