Example usage for android.app Activity finish

List of usage examples for android.app Activity finish

Introduction

In this page you can find the example usage for android.app Activity finish.

Prototype

public void finish() 

Source Link

Document

Call this when your activity is done and should be closed.

Usage

From source file:Main.java

public static void startActivityAndDestroy(Activity activity, Class<? extends Activity> clazz) {
    Intent intent = new Intent(activity, clazz);
    activity.startActivity(intent);/*from  w w  w  . j av  a  2 s . c o m*/
    activity.finish();
}

From source file:Main.java

public static OnClickListener createFinishListener(final Activity me) {
    return new OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            me.finish();
        }//from   w  w  w.  j ava  2 s  .co m
    };
}

From source file:Main.java

public static void startActivityAndFinish(Activity packageContext, Class<?> cls) {
    Intent intent = new Intent(packageContext, cls);
    packageContext.startActivity(intent);
    packageContext.finish();

}

From source file:Main.java

/**
 * @see android.app.Activity#finishAfterTransition().
 *//* ww  w .j a v  a  2  s  .  com*/
public static void finishAfterTransition(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.finishAfterTransition();
    } else {
        activity.finish();
    }
}

From source file:Main.java

public static void finishApplication(@NonNull Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        activity.finishAffinity();/*from w ww .  j a v  a 2  s . c  om*/
    } else {
        activity.finish();
        System.exit(0);
    }
}

From source file:Main.java

public static OnClickListener getFinishDialogOnClickListener(final Activity activity) {
    return new OnClickListener() {
        @Override//from w w  w  . ja v a  2 s.  co  m
        public void onClick(DialogInterface arg0, int arg1) {
            activity.finish();
        }
    };
}

From source file:com.dimasdanz.kendalipintu.util.CommonUtilities.java

public static void dialogConnectionError(final Context context) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context, 4);
    builder.setIcon(android.R.drawable.ic_dialog_info);
    builder.setTitle(R.string.title_dialog_server_error);
    builder.setMessage(R.string.message_dialog_connection_error);
    builder.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            Activity a = (Activity) context;
            a.finish();
        }/*from   w  w  w.  j a  v  a  2 s .  c om*/
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:Main.java

public static void startActivity(Activity activity, Class clazz, boolean isFinish) {
    Intent intent = new Intent(activity, clazz);
    activity.startActivity(intent);/*from  ww  w .  ja  va  2  s. c  o  m*/
    if (isFinish) {
        activity.finish();
    }
}

From source file:Main.java

public static void startActivity(Activity activity, Class claz, boolean finish, int delay) {
    Intent intent = new Intent(activity, claz);
    activity.startActivity(intent);//from  www .j a v a2 s .  c om
    if (finish) {
        activity.finish();
    }
}

From source file:Main.java

public static DialogInterface.OnClickListener getDialogFinishListener(final Activity activity) {
    return new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            activity.finish();
        }/*  w w  w .  j  av a  2  s  . c o m*/
    };
}