I have a problem what happens is that I create an intent after I start it and at the end the MainActivity must be destroyed but all that process is marking me an error because I am in the SearchData class and not in MainActivity in the same way with the alertDialogBuilder and the txtCode are marking error because those elements belong to MainActivity then I do not know how to solve those errors I read something from Context but I am not understanding it well and I do not know if that is all this is in AsyncTask that is in a separate class.
@Override
protected void onPostExecute(CheckIn result) {//se ejecuta cuando termina doingBackgroud()
frameLayout.setVisibility(View.GONE);
if (result != null){
Intent intentIndex = new Intent(MainActivity.this, IndexActivity.class);//Creo un intent
startActivity(intentIndex);//inicio la actividad
finish();//se destruye la actividad
} else {
System.out.println("primer error");
alertDialogBuilder.setTitle("ERROR..").setMessage("El codigo no se encontro").setCancelable(false).setPositiveButton("ACEPTAR", null).show(); //mensaje si no existe el checkin
txtCode.setText("");
} //./else
}