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

/**
 * Start the original activity, and finish the precondition activity.
 * /*from  w ww  . jav  a 2  s.c  om*/
 * @param preconditionActivity
 */
public static void startOriginalActivityAndFinish(Activity preconditionActivity) {
    preconditionActivity.finish();
    preconditionActivity
            .startActivity((Intent) preconditionActivity.getIntent().getParcelableExtra(EXTRA_WRAPPED_INTENT));
}

From source file:Main.java

public static void finishActivity(Activity activity) {
    activity.moveTaskToBack(true);
    activity.finish();
}

From source file:Main.java

public static void finish(Activity activity) {
    if (activity != null) {
        activity.finish();
    }
}

From source file:Main.java

public static void changeToTheme(Activity activity, int theme) {
    sTheme = theme;//from  w w w.  j a  va2s .c o  m
    activity.finish();
    activity.startActivity(new Intent(activity, activity.getClass()));
    activity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
}

From source file:Main.java

public static void finishActivity(Activity context) {
    if (!context.isFinishing()) {
        context.finish();
    }
}

From source file:Main.java

public static void restartActivity(Activity activity) {
    Intent intent = activity.getIntent();
    activity.finish();
    activity.startActivity(intent);// w w w .  j  a  v a  2  s . c o  m
}

From source file:Main.java

public static void newClearTask(Activity activity, Class<?> homeActivityClass) {
    activity.finish();
    Intent intent = new Intent(activity, homeActivityClass);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP
            | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivity(intent);/*from w  w  w  .  j a v a 2s .  com*/
}

From source file:Main.java

public static void startIntentActivityAndFinish(Activity activity, Intent intent) {
    activity.startActivity(intent);
    activity.finish();
}

From source file:Main.java

/**
 * Finish the given activity and start a home activity class.
 * <p/>//from   w  ww .  j  av a2 s .c om
 * This mirror the behavior of the home action bar button that clears the
 * current activity and starts or brings another activity to the top.
 *
 * @param activity
 * @param homeActivityClass
 */
public static void goHome(Activity activity, Class<?> homeActivityClass) {
    activity.finish();
    Intent intent = new Intent(activity, homeActivityClass);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    activity.startActivity(intent);
}

From source file:Main.java

/**
 * Finish the given activity and start a home activity class.
 * <p>// ww w  .  j  a  va  2  s.  c  o  m
 * This mirror the behavior of the home action bar button that clears the
 * current activity and starts or brings another activity to the top.
 *
 * @param activity
 * @param homeActivityClass
 */
public static void goHome(Activity activity, Class<?> homeActivityClass) {
    activity.finish();
    Intent intent = new Intent(activity, homeActivityClass);
    intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP);
    activity.startActivity(intent);
}