How to block app minimization and closure?

Asked

Viewed 418 times

0

I’m developing an app in java, Android Studio, which will serve as a menu, on tablets. I would like to block the minimization and closure of the same(I believe that the owner of the establishment does not want the customer to use the menu tablet for other functions).

I used some flags to hide the bottom bar...in order for the user to have difficulty minimizing.

View mDecorView = getWindow().getDecorView();
                mDecorView.setSystemUiVisibility(
                        View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                                | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                                | View.SYSTEM_UI_FLAG_IMMERSIVE
                );

But still, if he gets the bar, she’ll show up. I would like to lock the application on the screen. There’s a way to do it?

  • I believe that for security reasons, there is no way to make the operating system just display your application. What you can do is try to make it as difficult as possible for the user to close their application by setting onBackPressed() so that when pressed, it goes back to the initial menu. Now if the user presses the menu button ai is gone....

  • 1

    Simple, you need to define your app to be a Aucher. So it will be part of the home screen and your users will never be able to get out of it unless you want. One simple way is to use the Intent filter on the home screen: '<Intent-filter> <Category android:name="android.intent.Category.HOME" /> </Intent-filter>' .

  • @Welbertmoreira yes, I saw some examples of systems that run this way...only putting this piece of code in the manifest the app already begins to have this behavior?

  • Places this filter inside the main Activity in the Manifest

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.