Android examples for android.app:Activity Start
start Activity, Closing all the Activities, Add new Flag to start new Activity
import android.app.Activity; import android.content.Context; import android.content.Intent; public class Main{ public static void start(Context context, Class<? extends Activity> activity) { // After logout redirect user to Loging Activity Intent i = new Intent(context, activity); // Closing all the Activities i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Add new Flag to start new Activity i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Staring Login Activity context.startActivity(i);/*from w ww .j a v a2 s .co m*/ } }