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 restartPC(final Activity activity) {
    if (activity == null)
        return;/*  w  w w  . j a v  a2  s. co m*/
    final int enter_anim = android.R.anim.fade_in;
    final int exit_anim = android.R.anim.fade_out;
    activity.overridePendingTransition(enter_anim, exit_anim);
    activity.finish();
    activity.overridePendingTransition(enter_anim, exit_anim);
    activity.startActivity(activity.getIntent());
}

From source file:Main.java

public static void restartApp(final Activity activity) {
    if (activity == null)
        return;/*from  w  ww . j  a  v a 2  s . co  m*/
    final int enter_anim = android.R.anim.fade_in;
    final int exit_anim = android.R.anim.fade_out;
    activity.overridePendingTransition(enter_anim, exit_anim);
    activity.finish();
    activity.overridePendingTransition(enter_anim, exit_anim);
    activity.startActivity(activity.getIntent());
}

From source file:com.dgsd.android.ShiftTracker.StApp.java

public static void doDefaultNavigateUp(Activity a) {
    Intent upIntent = new Intent(a, StApp.getHomeClass(a));
    if (NavUtils.shouldUpRecreateTask(a, upIntent)) {
        TaskStackBuilder.create(a).addNextIntent(upIntent).startActivities();
        a.finish();
    } else {/*from  w  w w  .  j av  a 2s . co  m*/
        NavUtils.navigateUpTo(a, upIntent);
    }
}

From source file:com.samknows.measurement.util.LoginHelper.java

public static void openActivatingScreen(Activity acc) {
    Intent intent = new Intent(acc, SamKnowsActivating.class);
    acc.startActivity(intent);/*from  w w w .j  ava 2 s  .c  o m*/
    acc.finish();
}

From source file:Main.java

/**
 * Restarts activity, from http://stackoverflow.com/questions/1397361/how-do-i-restart-an-android-activity
 * @param activity the activity to restart
 *//*w w w .j av a  2s  .co  m*/
@TargetApi(11)
public static void restartActivity(Activity activity) {
    if (Build.VERSION.SDK_INT >= 11) {
        activity.recreate();
    } else {
        Intent intent = activity.getIntent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        activity.finish();
        activity.overridePendingTransition(0, 0);

        activity.startActivity(intent);
        activity.overridePendingTransition(0, 0);
    }
}

From source file:Main.java

public static void restartTW(final Activity activity) {
    if (activity == null)
        return;//www.  ja  v a 2s.  c  o  m
    final int enter_anim = android.R.anim.fade_in;
    final int exit_anim = android.R.anim.fade_out;
    activity.overridePendingTransition(enter_anim, exit_anim);
    activity.finish();
    activity.overridePendingTransition(enter_anim, exit_anim);
    activity.startActivity(activity.getIntent());
}

From source file:com.binomed.showtime.android.util.CineShowTimeLayoutUtils.java

/**
 * Set the theme of the Activity, and restart it by creating a new Activity of the same type.
 *//*from w w w.  ja  v a 2 s. c  o  m*/

public static void changeToTheme(Activity activity, Intent originalIntent) {
    activity.finish();
    Intent newIntent = new Intent(activity, activity.getClass());
    newIntent.replaceExtras(originalIntent);
    activity.startActivity(newIntent);
}

From source file:Main.java

public static <T extends Activity> void startActivity(Activity parent, Class<T> clazz, boolean killParent) {
    Intent intent = new Intent(parent, clazz);
    if (killParent) {
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    }/*  w  w  w  . j  a  v  a 2 s .c o  m*/
    parent.startActivity(intent);

    if (killParent) {
        parent.finish();
    }
}

From source file:Main.java

public static void finishActivity(Activity activity) {
    try {//from   w  ww .  jav a2  s .  c  o  m
        if (activity != null) {
            try {
                activityStack.remove(activity);
            } catch (Exception e) {
                e.printStackTrace();
            }
            activity.finish();
            activity = null;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void goTo(Activity aty, Class clazz, Bundle bundle, boolean isFinish) {
    Intent intent = new Intent(aty, clazz);
    if (bundle != null) {
        intent.putExtras(bundle);//from  w ww . j a v a2s.  co m
    }
    aty.startActivity(intent);
    if (isFinish) {
        aty.finish();
    }
}