12

I have read many question about whether it is possible to prevent an Android application from starting, but all of the answers seem to be "no, you cannot".

The idea is very simple: we want the user to be able to use a restrited set of applications that will be preinstalled on his mobile device. If the user tries to start a non authorized application, he will be prompted with a dialog asking for a PIN. If he enters the right PIN, then he will be able to run the application. Otherwise, the application will not be run.

As I said before, all the answers that I could find out there fall into two categories: "you can't do that" and "you can do that by writting your own launcher application".

However, I have seen applications such as ZDBox, which allow you to do just that. That is, with ZDBox you can define "non authorized" apps, in such a way that if the user tries to start one of them, he will need to enter a PIN to actually start the app. If he fails to provide one, the app will not start. The funny thing is that ZDBox does not require root access to do this.

So my question is, how can we prevent other apps from starting, just as ZDBox does?

0

1 Answer 1

4

Option 1

All the examples I've seen involve running your app as a Launcher/Home Screen replacement. This is how all the child lock style apps I've used work. This has the advantage

  • Pressing Home button doesn't leave the app
  • You have control of app launching

You can check out the android Launcher2 code to see how the Android launcher works. https://android.googlesource.com/platform/packages/apps/Launcher2.git

Option 2

There does look to be one alternative that I can see. In that you can try and read the logcat entries to detect when a blacklisted app is launched or brought to foreground and then launch your app over the top.

Similar to how they detect an app launch in How to detect when the user launches another app? (Android)

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

12 Comments

But ZDBox is not a launcher application. It is a standalone app that can prevent other apps from running. You can download it and try it (its free).
True. Just checked it out and it doesn't replace the launcher. I've updated to add a second option to detect app launches with logcat monitoring.
Hmmmm, that seems to be an interesting approach. However I do not undestand what you mean by "launching my app over the top". I mean, we can now detect the user launching an app, but how can we now prevent him from running it if he does not provide a valid PIN?
If every time your monitoring service sees a black listed app being brought to foreground, you check if the pin has been entered and if not call startActivity on your pin screen activity. This will mean that you're pin lock screen will always been in the foreground.
Intent dialogIntent = new Intent(getBaseContext(), PinLockActivity.class); dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getApplication().startActivity(dialogIntent);
|

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.