Search code examples
androidtabletrom

Disable app from closing Android


I need to create an app that cannot be closed on Android, neither by the home button or the back button. Currently I am looking into creating my own ROM as the app does not need to be published it is an internal app for my company, but was thinking if there is any other easier options.


Solution

  • As mentioned by @Commonsware, you need to make your application a launcher (Homescreen).

    Also, You can keep a service running which every half milliseconds check which activity is on top, if it is any other activity, other than yours, then it pushes your activity to top.

    You can use the PackageManager to get the current top activity.

    Also, the back button press can be easily handled, in your app, just remove the super call in onBackPressed