Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.Activity; import android.os.Build; import android.support.annotation.NonNull; public class Main { public static void finishApplication(@NonNull Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { activity.finishAffinity(); } else { activity.finish(); System.exit(0); } } }