android how to close app programmatically

www.lau‮utt‬ri.com
android how to close app programmatically
// android close app on back button 

public void onBackPressed(){
    Intent act = new Intent(Intent.ACTION_MAIN);
    act.addCategory(Intent.CATEGORY_HOME);
    act.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(act);
}
Created Time:2017-08-31 05:27:17  Author:lautturi