简体   繁体   中英

Stop execution in Activity when starting a new activity

I'm evaluating a case and the truth is not the way I want. Depending on a true or false value, the application must do something, if true, should go to another view so I do the following:

if(metodoRut){
   inscripcion = nueva.getInscripcionByRut(rut,codigoEvento ,this);
   if(nueva.getCantidadInscripciones(this, rut) > 1){
      Intent intent = new Intent(this,ValidacionMultiple.class);
      System.out.println(intent.toString());
      startActivity(intent);
    }
}else{
   inscripcion = nueva.getInscripcion(rawResult.getText(),codigoEvento,this);
}
/* 
 * more code
 * /

If I need to run it meets the Intent, but that happens. Sign in if makes everything that comes after the IF and then launch my new view.

If I understood what you were trying to say it's that the code you have where the more code comment is executes even after you called startActivity

The easiest fix for that (which may not be the best or cleanest solution) would be to call finish() immediately after startActivity()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM