2

Is it possible to lock a user in an activity, so that it is impossible to navigate away from it without entering a pin or in other ways "unlocking"? If so, how?

Would be very useful for a an app used in a public setting, like a tablet on display.

rogerkk
  • 5,494
  • 5
  • 37
  • 53
  • 1
    Have a look at http://stackoverflow.com/questions/10625413/is-it-posible-to-use-a-device-to-run-one-application-exclusively/10625480#10625480 – RPB Apr 27 '13 at 05:48

3 Answers3

3

It is possible, but involves lots of trickery. See the commercial app SureLock which probably does what you want.

If you want to try it yourself, start with redefining the home screen in the AndroidManifest.xml, using

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.HOME" />
</intent-filter>

This will ask for the user's permission when called the first time. It gets complicated when you also want to lock down the recent activities and access to the settings menu.

So, the short answer is yes.

RPB
  • 16,006
  • 16
  • 55
  • 79
0

I am not sure is there something already available on android, but I think you can check authentication through this method onUserInteraction

Gopal
  • 1,719
  • 12
  • 13
-1

You cannot stop the user from navigating away from your application via the home button (and you cannot stop other activities from opening). However you are notified when these things happen through your onPause() callback, and if the user returns to you, onResume() is called. You can require a pin at the point of resumption.

mah
  • 39,056
  • 9
  • 76
  • 93