title: Android stop user from closing the app
body: <p>Is there a way we can build a custom MDM, to force the app to be always open. i.e don't let the user close.</p>
  
  <p>I am building a image gallery app to be on display for users. but I dont want them to be able to close my app.</p>
  
  <p>Thanks </p>
  
  <p>some thing like this ? </p>
  
  <pre><code>public class IntentReceiver extends BroadcastReceiver {
      public static final String TAG = IntentReceiver.class.getSimpleName();
  
  
      @Override
      public void onReceive(Context context, Intent intent) {
          Log.i(TAG, "onReceive - intent =&gt; " + intent.getAction());
  
          //Get Intent
          String action = intent.getAction();
  
          if("android.intent.category.HOME".equals(action)) {
  
              Intent i = new Intent();
              i.setClass(context, MainActivity.class);
              i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              context.startActivity(i);
          }
  </code></pre>
  
  <p>But then, I also need to know when the app is closed or killed ?</p>
  
  <blockquote>
    <p>Let me try to explain better. imagine if an artist wants to display his work via 10 android device. all in the Wall. So he can use this app. I want to lock-down the device. to only run this app and nothing else to work. 
    Similar conset when you go to a phone shop and all the device is running a demo app and you can't quit it with out a password. (i.e Apple Store) you can't quit the app running on these Ipads </p>
  </blockquote>