Android How to - Start Activity withno History








Question

We would like to know how to start Activity withno History.

Answer

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
//  w ww. jav  a  2s .com
public class Main {
  public static void jumpWithNoHistory(Context old,Class<?> cls,int requestCode,Bundle mBundle){
       Intent intent = new Intent();  
        intent.setClass(old, cls);
        if(mBundle != null){
          intent.putExtras(mBundle);
        }
        
        Activity activity = (Activity) old;
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        activity.startActivityForResult(intent, requestCode); 
    
  }
}