onPostExecute方法根本没有被执行,我在LogCat看到了36但我在LogCAT中看不到13。我尝试调试它,它似乎在return语句之后转到类的第一行(包行)。
private class Client extends AsyncTask<Integer, Void, Integer> {
protected Integer doInBackground(Integer... params) {
Log.e(TAG,10+"");
try {
socket = new Socket(target, port);
//socket.setSoTimeout(3000);
Log.e(TAG,31+"");
oos = new ObjectOutputStream(socket.getOutputStream());
Log.e(TAG,34+"");
ois = new ObjectInputStream(socket.getInputStream());
Log.e(TAG,35+"");
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Log.e(TAG,36+"");
return 1;
}
protected void onPostExecute(Integer result) {
Log.e(TAG,13+"");
try {
Log.e(TAG,12+"");
oos.writeUTF(key);
Log.e(TAG,16+"");
if (ois.readInt() == OKAY) {
isConnected = true;
Log.e(TAG,14+"");
}else{
Log.e(TAG,15+"");
isConnected = false;
}
} catch (IOException e) {
e.printStackTrace();
isClosed = true;
}
Log.e(TAG,19+"");
}
}
在logCat中看到的数字:
10
31
34
35
36
之后没有。