What is wrong with this Asynchronus task?
Posted
by
bluebrain
on Stack Overflow
See other posts from Stack Overflow
or by bluebrain
Published on 2012-03-30T23:24:50Z
Indexed on
2012/03/30
23:30 UTC
Read the original article
Hit count: 167
the method onPostExecute simply was not executed, I have seen 16 at LogCat but I can not see 16 in LogCAT. I tried to debug it, it seemed that it goes to the first line of the class (package line) after return statement.
private class Client extends AsyncTask<Integer, Void, Integer> {
protected Integer doInBackground(Integer... params) {
Log.e(TAG,10+"");
try {
socket = new Socket(target, port);
Log.e(TAG,11+"");
oos = new ObjectOutputStream(socket.getOutputStream());
Log.e(TAG,14+"");
ois = new ObjectInputStream(socket.getInputStream());
Log.e(TAG,15+"");
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Log.e(TAG,16+"");
return 1;
}
protected void onPostExecute(Integer result) {
Log.e(TAG,13+"");
try {
Log.e(TAG,12+"");
oos.writeUTF(key);
Log.e(TAG,13+"");
if (ois.readInt() == OKAY) {
isConnected = true;
Log.e(TAG,14+"");
}else{
Log.e(TAG,15+"");
isConnected = false;
}
} catch (IOException e) {
e.printStackTrace();
isClosed = true;
}
}
}
© Stack Overflow or respective owner