Exits the app to the Home screen. - Android User Interface

Android examples for User Interface:Screen Lock

Description

Exits the app to the Home screen.

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.Intent;

public class Main {
    /**/*  w  ww  .j av  a  2s  . co m*/
     * "Exits" the app to the Home screen".
     * @param context Application context
     */
    public static void exitToHome(final Context context) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }
}

Related Tutorials