Android: Prevent users from launching apps or using the OS - android

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.

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.

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

Related

Make my Android app to fully kiosk mode when enabled

I am trying to make my feedback app to support fully kiosk, I have tried a lot of solutions but Nothing is completely satisfying my need. Here are the things that I found yet.
1. Make my app as Device Admin/Owner App(Lock Task) -
If we follow this link/procedure https://developer.android.com/work/dpc/dedicated-devices/lock-task-mode, some limitations are there as follows -
a. We have to factory reset all the devices where Feedback app is installed, follow some steps to make it as admin app(launcher app).
b. Installation of the app will be possible using the command line, each installation will take some line of code through cmd, which means for installing a person has to go there with the computer and connect the device with USB and then install the app using commands.
c. Update on an app will also follow the same procedure (Couldn't be performed using google play store)
d. In this case, end-user will never be able to exit from our app, restart the device would also launch the same feedback app every single time.
2. Programmatically screen pinning + programmatically volume and power button controlling. (https://github.com/mrugacz95/kiosk)
a. In this, we will make the app in screen pinning mode where all the three bottom buttons(Overview, home, recent) will be hidden/disabled. and same with the power key and volume keys.
b. So As soon user clicks on kiosk mode, a screen pinning system generated prompt would be shown to user But the biggest disadvantage of it is that app would be unpinned/unlocked as soon as the user presses overview+recent buttons together.
3. The third Case is, where all the keys are controlled including power+voulme+back+overview etc.
Only pressing home will make the app to go on the background and within seconds it will again come foreground.
So all I found up until now, is not very satisfiable.
One more Question-
Is this something to be fully controlled by MDM(Mobile Device Management)?
Any help is appreciated.
1. Make my app as Device Admin/Owner App
a. A device owner can only be installed on a newly initialized device (before an account is added). I believe this is by design : A device owner can completely lock the device down, you don't want a malicious app to be able to seize the phone of an unsuspecting user after a few "I agree" popups.
b. You don't need to install it using adb. The simplest provisioning method is via NFC : While the device shows the very first screen of the setup wizard, touch it with a tag (or another device) containing the provisioning configuration, most importantly an URL where the apk can be downloaded and a WiFi config.
Another method is via QR code (Android 7+) : tap 6 times the first setup screen. It is a bit less convenient than NFC because you usually have to provision the WiFi manually.
c. A device owner can be updated like any other app. As it can itself install or update applications without asking the user, you can implement a fully automatized self update mechanism : check for update / download / update.
2. Lock task / screen pinning
Any application can programatically enter lock task mode. How it happens depends on whether the application is white listed by a device owner app (possibly itself) :
If not, the user is prompted and must accept, they can also exit at any time. This is basically the same thing as screen pinning.
If yes, there is no popup : the user can not decline to enter, nor exit, the lock task mode.
Additionally a kiosk application can act as a launcher. A device owner (again, possibly itself) can set it without user intervention
Is this something to be fully controlled by MDM(Mobile Device Management)?
While device owner apps are usually DPC connected to a MDM console of some sort, this is not a technical requirement. How you control it is completely up to you. (I hope I understood correctly the question)
Overall, I think that the only reliable way a device can be locked in kiosk mode is to use a device owner app (separately or included in the kiosk application). The setup via NFC or QR code is actually faster than a normal device setup. It can also protect against safe mode reboot or factory reset. The only real constraint is that you can not deploy this kind of application on existing devices without wiping them first.
Make my app as Device Admin/Owner App(Lock Task) -
a. If you are making it an 'admin app' this means you have signed the device image correct? Therefore you control the full flashing of the device - you can do anything in this scenario.
b. You can actually also do ADB over WiFi after you set it up the first time
c. You can update your apps from the playstore - even launcher applications
d. This fact is the whole point of Kiosk mode. Users should not ever be able to exit the application. Only you can exit, either with a remote command or with a invisible touch combination (for example touching each of the corners of the screen in sequence twice, or other 'secret unlock code')
Programmatically screen pinning + programmatically volume and power button controlling. (https://github.com/mrugacz95/kiosk)
b. This is the opposite of 1d, it is not clear what you want if you want neither.
The third Case is, where all the keys are controlled including power+voulme+back+overview etc.
This is also the opposite of 1d, it is not clear what you want if you want neither.
We need a few more details on your deployment scenario for this app to help you out further.

stopping the user from forcing stop my app

About Android (6.0 to the last version)
I'm developing an app and we want that the user, once he accepts all the terms, don't be able to kill the process or force stop the app. Honestly, I'm completely lost right now, because on the last versions of android, and specially some brands like Xiaomi, we are having a lot of trouble with it, and we don't know how to act right now.
In the case that it could not be possible, could at least get an alert whenever the user is killing the app?
Thanks!!
It is not possible to prevent the user from killing an app. Android is a unique system where the app has no direct control over its lifecycle but the system has. The system can (and will, when required) kill the app or any of its processes at its own will. To make your app aware of these changes, the android framework provides for various callbacks such as onPause, onStop and onDestroy which are called in succession when the user kills the app.
Side Note : There is no guarantee that onDestroy() will be completely executed when the app is killed. Do not place essential code there.
Of course, you can block or try to prevent the user from closing your app by overriding the back, home and recent buttons but it is highly recommended not to do so. Even if you do so successfully, the user has other means to close your app such as rebooting their phone.
So what to do?
You are looking for a kiosk mode app. Kiosk mode is used for single purpose phones such as at a restaurant or for a cab driver. Kiosk mode apps lock down the user to only a specific app (or a specific set of apps).
For normal apps, it is not possible to prevent the user from force closing your app. You can only get alerts by checking for lifecycle changes as described above. Moreover, it is not at all recommended to change the natural behavior of the hardware buttons on android. The user can still find a way to close your app. If your app is doing something really essential which should proceed in the background, consider using a service for that instead. Also, the user can uninstall your app at anytime if they find your app being too intrusive and you won't be able to do anything in that scenario.
Tl;dr: Use kiosk mode to prevent the user from exiting the app. This will only allow the user to access your app(s) in their device.
Usually you cannot! Even if you try to disable some buttons, user can always stop app or restart device. In addition at times, the OS will stop the App. Your responsibility as a programmer is to program around this, and give the user the feel that it never stopped. If you are doing background monitoring, you will need to use service. Users will still be able to stop service. Having said that, you can set your app as a Device Administration app, see here, which may disallow stopping, but unless you are distributing internally to a company, noone will install.

Android application which you cannot close

Is there any programming tricks that makes your application unclosable?
For example: You touch the back or the home button, but they don't do anything.
Or at least is there a way that your application blocks some applications to open?
I don't think you can stop user from moving your application to background unless it's some kiosk mode app. And the method to do that is to become device administrator and override all possible callback methods - home, back, settings, notification area etc.
If you just want to prevent your app from getting closed due to user activity you can show a persistent notification. This will allow you app to run in background even if user presses home button.
Make a launcher/Home screen app:
When users click the home button, your app will show.
You control ALL apps that can be started
On devices running android lolipop, you can use the screen pinning option available in your ROM.
NOTE: This is ROM feature, you don't have to do anything in your app.
See this great article about it.
yes its to get set the on backpressed method to.
moveTaskToBack(true);
finish();
Are you trying to hack in android OS ? Let me tell you that android apps are sandboxed, which isolates your app data and code execution from other apps.

a persistence and startup service to support an app

I own an android 4.0.3 tablet and I'm programming in Java/SDK, still not tried NDK.
Now, suppose that you want to program this tablet to put it in a service point, with a single use case, like a restaurant, where it would show menus and let the user pass them. I would like not to let the user to shut down this software. Also, it must automatically runs at tablet start up and persisnts on, i.e. if it shuts down by some reason, the tablet should not go back to its standard GUI but to restart this application.
I don't know any start point for this, like some keywords etc. I imagine that here I must code a service (that maintains the persistence and startup of the application) and the application itself.
Could you please give some ideas / keywords / potential start points / comments?
Thank you in advance.
Here some things you need to check:
1.) How to start an application at boot.
2.) How to run a service/thread in background to check if the application is running and if not to start it.
3.) How to deactivate buttons, ie like the "back" button to not exit the app or program a way that the activity never exits with user interference. (That is very bad practice though!) :)
4.) There should be a way to exit the application though for maintenance purposes. Be creative in that one. Maybe exit only with password or something.
I would like to not to let the user to shut down this software so it must persist.
Make it be the home screen.
Also, it must automatically runs at tablet start up and persisnts on, i.e. if it shuts down by some reason, the tablet should not go back to its standard GUI but to restart this application and represent its GUI.
Make it be the home screen.

Android OS - Stop user from closing app or using any OS functionality

My team is trying to build an Android application for a tablet that will be dedicated for this sole purpose. One of the requirements is that the application is the only thing running on the device (at least from the user's point of view). The user should not be able to close it or use any other functionality from the OS (settings, other apps, etc.).
We have been doing some research and so far have not found anything. Is this we are trying to do even possible ? Does anybody have any idea how we could approach this ? Maybe blocking the buttons ?
Thanks,
It is possible but would be ugly in the long run without a custom built rom (http://xda-developers.com has instructions on how to do this), I wouldn't know where to start code wise - but there are a couple of applications which portray this kind of functionality - TodlerLock is one such app - its designed to stop todlers from from doing anything on the device, whilst the application keeps them entertained. It appears to intercept all button presses and acts as a home application to do this for the home button.
Then there are the programs like estrongs security manager that allows a user to set a password for some or all applications and basically stops the application being run without the password (it appears to intercept the intents and opens the security manager requesting the password first, if it fails it finishes the intent) - this maybe a much easier option to use something like this - you could set a password for most things, including settings and the security application itself, everything bar your application. This will stop the user doing anything you dont want them doing without the password.
You would have to set up the device for the user before hand though, as any home screen intercepter application can be changed but the user - so you would have to set the default, then lock access to the settings so the user can't change this action.
I think the only way of doing this to have your own custom version of Android built only for you. Get the android source, remove what ever you don't want and build it. I am not sure if you would ever want not to close it but you can make sure they can't install anything else on your ROM.
Im not sure about this, but, intercept the home intent and write your own custom home?
It sounds a lot simpler than writing your own custom rom.
This is not possible without OS changes. You cannot override the home button.

Categories

Resources