I have this class:
abstract public class ListaEstaticaDeErros {
private static ArrayList<DescritorDeErro> listErros = new ArrayList<DescritorDeErro>();
private static boolean fimSinc = false;
private static int municipio = 0;
public static boolean getFimSinc(){
return fimSinc;
}
public static int getMunicipio(){
return municipio;
}
public static void setMunicipio(int i){
municipio = i;
}
public static void setFimSinc(boolean b){
fimSinc = b;
}
public static void setListErros(ArrayList<DescritorDeErro> list){
listErros = list;
}
public static void addRegListErros(DescritorDeErro obj){
listErros.add(obj);
}
public static ArrayList<DescritorDeErro> getListErros(){
return listErros;
}
}
Activity function that I try to retrieve and show the size of the list:
public void montarResultados(){
Log.e("Teste-esus", String.valueOf(ListaEstaticaDeErros.getListErros().size()));
Bundle bundle = getIntent().getExtras();
ArrayList<DescritorDeErro> lst = bundle.getParcelableArrayList("lista");
int mun = bundle.getInt("municipio");
String usuario = bundle.getString("usuario");
if(lst.size() > 0) {
new ChargeList().execute(lst, mun, usuario);
}else{
txtVInfo.setText("Nenhum erro capturado ate este momento de sincronização.");
}
if(bundle.getBoolean("fim_sinc")) {
txtEmail.setVisibility(View.VISIBLE);
}else{
txtEmail.setVisibility(View.INVISIBLE);
}
}
And within an activity I need to retrieve this list and it always returns me 0, that is without any element, but if I get it in another class that is not an activity I get it without problems, so the solution I did was get it in another class and send via intent to the activity I need, but I would like to take it directly from the activity so I can implement what I need.