0
在Asynctask中onPostExecute方法沒有被調用,但是,Logcat在doinbackground中的方法之後也沒有打印。有任何想法嗎?Aysnctask在它應該調用onPostExecute方法時
public class connectTask extends AsyncTask<String,String,String[]>
{
String FilmId, Name, Certificate, Duration, Director, Description, ReleaseDate, Cast;
@Override
protected String[] doInBackground(String... params) {
//we create a TCPClient object and
mTcpClient = new TCPClient(new TCPClient.OnMessageReceived() {
@Override
//here the messageReceived method is implemented
public void messageReceived(String message) {
//this method calls the onProgressUpdate
//Log.e("TCP Client", message);
try
{
JSONObject json = new JSONObject(message);
FilmId = (String) json.get("FilmId");
Name = (String) json.get("Name");
Certificate = (String) json.get("Certificate");
Duration =(String) json.get("Duration");
Director = (String) json.get("Director");
Description = (String) json.get("Description");
ReleaseDate = (String) json.get("ReleaseDate");
Cast = (String) json.get("Cast");
Log.e("FilmId: ", FilmId);
Log.e("Name: ", Name);
Log.e("Cert: ", Certificate);
Log.e("Duration: ", Duration);
Log.e("Director: ", Director);
Log.e("Description: ", Description);
Log.e("ReleaseDate: ", ReleaseDate);
Log.e("Cast: ", Cast);
JSON[0] = FilmId;
JSON[1] = Name;
System.out.println(JSON[1]);
Log.e("work","work");
}
catch (JSONException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
mTcpClient.run("");
Log.e("work","please");
return null;
}
@Override
protected void onPostExecute(String[] result) {
// TODO Auto-generated method stub
Log.e("work","goddammit");
Intent FilmInfo = new Intent(FullscreenActivity.this, FilmInfo.class);
FilmInfo.putExtra("NamePass", JSON[1]);
FullscreenActivity.this.startActivity(FilmInfo);
super.onPostExecute(result);
}
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
}
}
我已經檢查了各種其他問題,他們沒有幫助。 我使用Override/Implement方法自動在Eclipse中創建方法,以確保它們正確地形成。
你怎麼稱呼它?你可以展示更多的代碼! –
是不是'mTcpClient.run(「」);'阻塞線程?也許你應該在收到消息後釋放它。只是猜測,我從來沒有與TCPClient合作過。 –
@ tato.rodrigo你是正確的,mTCPClient被阻止。 –