At last it seems a hardware problem, i execute the code in a much powerfull computer and works, maybe due to heavy work my application freeze? i don´t know, thanks
My AsyncTask is stuck in doInBackground() forever [closed]
-
24-06-2023 - |
Frage
i have a program where i consult google spreadsheets, i do it in a AsyncTask but is very slow so i want to put a ProgressDialog, i show it on onPreExecute method but my program can´t execute doInBackground method, howewer i can see that app enters in this method thaks to Log.i, but don´t do nothing, i can see Progress dialog but nothing else, it´s like an infinite bucle
My AsyncTask is like this:
private class GestionDatos extends AsyncTask<Void, Void, ArrayList<String>> {
@Override
protected void onPreExecute(){
super.onPreExecute();
mProgress = ProgressDialog.show(MainActivity.this, "Trabajando", "Espere por favor");
}
@Override
protected ArrayList<String> doInBackground(Void... params) {
SpreadsheetService service = new SpreadsheetService("com.banshee");
ArrayList<String> nombres = new ArrayList<String>();
String idAnterior = "idAnterior";
try {
String urlString = "My URL";
URL url = new URL(urlString);
ListFeed feed = service.getFeed(url, ListFeed.class);
for (ListEntry entry : feed.getEntries()) {
CustomElementCollection elements = entry
.getCustomElements();
String id = elements.getValue("Codigo");
if (idAnterior.compareTo(id) != 0) {
idAnterior = id;
String name = elements.getValue("Profesor");
nombres.add(name);
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
}
return nombres;
}
@Override
protected void onPostExecute(ArrayList<String> result){
super.onPostExecute(result);
mProgress.dismiss();
values = result;
}
}
Sorry for my bad English and please be patient, i'm a noob android programmer
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow