Android examples for Activity:Activity Restart
restart Activity
//package com.java2s; import android.app.Activity; import android.content.Intent; public class Main { public static void restart(final Activity thiz) { restart(thiz, thiz.getIntent()); }// w w w .ja v a2 s. co m public static void restart(final Activity thiz, Intent intent) { intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); thiz.overridePendingTransition(0, 0); thiz.startActivity(intent); thiz.overridePendingTransition(0, 0); int flags = intent.getFlags(); boolean isClearTop = (flags & Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0; boolean isSingleTop = (flags & Intent.FLAG_ACTIVITY_SINGLE_TOP) != 0; if (!isClearTop && !isSingleTop) { thiz.finish(); } } }