josuto59
19/12/15, 20:03:20
Hola compañeros, que estoy haciendo mal para que la clase ReadInputTask no invoque nunca al metodo onPostExecute, segun android developers debe hacerlo despues de doInBavkground. Os pongo el codigo:
private class ReadInputTask extends AsyncTask<InputStream, String, String> {
@Override
protected String doInBackground(InputStream... inps) {
//String p;
InputStream inputStream = inps[0];
byte[] buffer = new byte[256]; // buffer store for the stream
int bytes; // bytes returned from read()
while (true) {
try {
// Read from the InputStream
bytes = inputStream.read(buffer);
if (bytes > 0) {// Get number of bytes and message in "buffer"
publishProgress(new String(buffer, 0, bytes, "UTF-8"));
// p.concat(byte[]):
}
} catch (Exception e) {
// To be done
}
}
}
protected void onProgressUpdate(String... values) {
String input = values[0];
appendText(input);
}
//@Override
protected void onPostExecute(String... result) {
loQueSea();
}
}Venga, a ver si podeis hecharme una mano y voy acabando el proyecto.
Muchas gracias
private class ReadInputTask extends AsyncTask<InputStream, String, String> {
@Override
protected String doInBackground(InputStream... inps) {
//String p;
InputStream inputStream = inps[0];
byte[] buffer = new byte[256]; // buffer store for the stream
int bytes; // bytes returned from read()
while (true) {
try {
// Read from the InputStream
bytes = inputStream.read(buffer);
if (bytes > 0) {// Get number of bytes and message in "buffer"
publishProgress(new String(buffer, 0, bytes, "UTF-8"));
// p.concat(byte[]):
}
} catch (Exception e) {
// To be done
}
}
}
protected void onProgressUpdate(String... values) {
String input = values[0];
appendText(input);
}
//@Override
protected void onPostExecute(String... result) {
loQueSea();
}
}Venga, a ver si podeis hecharme una mano y voy acabando el proyecto.
Muchas gracias