3

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.

9
  • Well it is for testing other software in my lab, not for putting it out on the market to annoy people. Commented Oct 12, 2014 at 11:55
  • 1
    If it's just for your lab, just don't press the back button. Commented Oct 12, 2014 at 11:58
  • I don't want to be smacking people's hands all day when they do that. Commented Oct 12, 2014 at 11:58
  • Again it won't be published. Commented Oct 12, 2014 at 12:05
  • 1
    Disabling the back button is incredibly easy (just override onBackPressed()), I think the home button is intentionally difficult to reconfigure though Commented Oct 12, 2014 at 12:07

2 Answers 2

3

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 - ..

Sign up to request clarification or add additional context in comments.

4 Comments

That's awesome I am using L! Forgot to mention.
@FrankN.Stein there are valid use cases for this
@J_Strauton great! you might then want to consider accepting the answer
@ligi ... for instance?
0

It seems google has some thing called COSU for setting up single-purpose devices

Android 5.0 Lollipop introduced two new ways to configure Android devices for a single purpose:

  • With app pinning, the device user can temporarily pin specific apps to the screen.
  • With lock task mode, a user can’t escape the app and the Home and Recents buttons are hidden. Additionally, lock task mode gives the IT administrator a more robust way to manage COSU devices, as discussed below.

and

As an IT administrator, you can configure Android 6.0 Marshmallow and later devices as corporate-owned, single-use (COSU) devices. These are Android devices used for a single purpose, such as digital signage, ticket printing, point of sale, or inventory management. To use Android devices as COSU devices, you need to develop Android apps that your customers can manage.

from here

and there is a code lab for it here

for earlier versions of android here i founded How-To Create a Working Kiosk Mode in Android which shows some hacks for disabling buttons and restarting the application after boot and lock. note that most of these hacks, don't work on android 6 and later

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.