2

Is it possible to have an application run on a device in such a way that it is the only application that can ever run and also prevent the user from using the operating system at all? Tapping on the Home key or Back button would not exit the application and allow the user to have access to anything. If the device boots up, only this application would run.

This would be desirable in situations where devices are installed at a business for point of sales purpose or possibly where the device acts like a terminal in public places.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Johann
  • 27,536
  • 39
  • 165
  • 279

2 Answers2

2

You can achieve what you're describing by writing your app to replace the home screen (Launcher). From there, you control what other apps will run.

The Android SDK has a working Launcher project you can start from.

Be careful to allow some method of running a more powerful app (even if it's just enabling ADB access) -- otherwise you could leave your device in a state of needing a factory reset before it can be modified.

mah
  • 39,056
  • 9
  • 76
  • 93
  • This needs root permission isn't it? – rekire May 30 '12 at 11:17
  • Is it not possible for something to happen in the OS where suddenly a dialog pops up that could in effect provide the user an alternative way to access the system. For example, if memory got low, the OS might popup a dialog that allows the user to be taken to Manage Applications. That's just one example. There probably are a lot more. In other words, is there any guarantee to suppress any OS interaction? – Johann May 30 '12 at 11:18
  • @rekire no, root permission is not required. There are numerous Launcher replacements available on the Market if you wish to verify. – mah May 30 '12 at 11:19
  • @AndroidDev I'm not aware of standard means of the OS doing what you describe however you can manage this through your Activity Lifecycle (onPause, etc.) methods, or through monitoring the topmost activity to ensure it's one you approve of. However, if you're controlling the environment, a low memory situation should never happen, no? – mah May 30 '12 at 11:21
  • I would imagine that OS functionality will always have a higher priority over any app and if it requires the user's attention for whatever reason, it will display a dialog and/or take the user to something outside of the app. That's just my guess. The app wouldn't be trying to manipulate the OS. It just needs to prevent user accessing stuff where possible. – Johann May 30 '12 at 11:26
  • I read the link from Daniel I didn't know that. I need that for one app I wrote too. – rekire May 30 '12 at 11:29
  • @AndroidDev - the OS may be able to do this however you can still circumvent it by re-asserting your application. Your app can get in front of any other app by simply asking to. That being said, it sounds like you would be more interested in replacing the OS with your own version of it; many devices allow you to do this (but of course it's much more work than just creating a Launcher replacement). – mah May 30 '12 at 11:29
  • Is it a safe/recommended way to use a Launcher app when the device will be used in a public place? How about in a working environment where the employees should only be using the exclusive app. A private business would be less critical. In a public place, you've got all kinds of people who could screw things up if given the chance. – Johann May 30 '12 at 11:33
  • @AndroidDev replacing the stock OS with one of your own customization will be more secure if you've got the knowledge/ability/resources to do that. Without that step though, you can probably achieve your goal in all but the most extreme circumstances by just writing a Launcher replacement that monitors the topmost application. This is how the many "app lock" apps on the Market work. One item to be aware of with that approach though is a small time window for the user accessing "locked out" areas. – mah May 30 '12 at 11:40
2

Yes, you can override the back and home button behaviour.

Start app, override all buttons, and the user cant exit the app, evil, but should work in your scenario.

info here

Community
  • 1
  • 1
Daniel Magnusson
  • 9,541
  • 2
  • 38
  • 43