Prevent users from closing or minimizing Android app

I have an Android app where a client will be given two tablets to experiment with.

Q: can users be prevented from minimizing or closing the application? How can i do this?

+3


source to share


2 answers


Kiosk mode is what you are looking for! It was introduced in Android 4.2.

To enable kiosk mode, set it to activity_main.xml

:



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

      

This question is most likely a hoax: Developing a kiosk mode app in android

+6


source


I tested the way ... This is done on a fragment, you can test it yourself to do it from an activity.

public void onDestroyView() {
    if(condition) {
        Intent intent = new Intent(getContext(), MainActivity.class);
        startActivity(intent);
    }
    super.onDestroyView();
}

      



This is done from Activity B with a snippet on it, and then from the main activity returns to Activity B. In this case, the user cannot close the application

0


source







All Articles