Application that keeps itself on top, and re-launch itself when closed
I need to "lock" a user into an application. The device's sole purpose is to use this application, and so it is not feasible to allow the user to navigate the device for any other re开发者_高级运维ason. What is the best way to make sure that the applications Activity
s are always in the foreground, and if not, launch the main Activity
?
Now I know this goes against everything about the typical Android application development, but these devices are going to be specifically used for this one application.
What is the best way to determine if any of the applications Activity
s are in the foreground, and launch one if not?
What is the best way to make sure that the applications Activitys are always in the foreground, and if not, launch the main Activity?
You don't.
Make your activity be the home screen, and they can't go anywhere. And roll your own firmware, so that the user can't safe-boot the device and remove your home screen.
I will probably use a service which gonna check using a flag as example for a living activity.
Look here for more detail about how to do : http://developer.android.com/guide/topics/fundamentals.html
See the answer to this question: basically you must implement a second app that captures home intents and simply re-launches your primary application if it is ever closed.
In reference to what CommonsWare was saying, you could actually partially brick the device. I've done it on accident where I've bricked the recovery menu, but not the actual regular boot. This is a terrible idea of course and should not be used practically.
精彩评论