我正在開發一個Android應用程序。現在我想使用一個AsyncTask。它在android 4.1中運行完美,但doInBackground方法不在android 2.3.3中運行。有沒有錯誤logcat ..異步任務未運行2.3.3中的doInBackground
我有一個類,擴展vom AsyncTask。所以我用新的Class()。execute()來啓動它。構造函數總是有效的。
你有什麼想法我可以在android 2.3.3中解決這個問題嗎?
編輯: 我的代碼:
private class TopicList extends AsyncTask<String, Integer, String> {
private TopicList(){
Log.e("Constructor","Works");
}
@Override
protected String doInBackground(String... arg0) {
Log.e("InBackground","Works");
new Thread(new Runnable() {
public void run() {
// Network processes
}
}).start();
return null;
}
}
我有目標版本17的minSdkVersion 7.你還需要更多的信息?我使用此代碼執行它:
new TopicList().execute();
logcat中的錯誤日誌只顯示構造函數的工作原理。
你需要更具體。有數百個應用程序依賴於運行在薑餅上的AsyncTask。它*做*工作。 – 2013-03-27 14:40:23
你有'AsyncTasks'的錯誤。您不需要在'doInBackground'中啓動一個新的'Thread',因爲它已經在不同的線程上爲您自動完成了。 – Shade 2013-03-27 14:52:20
好的,那是對的。但它不能幫助我解決問題。我應該改變它。 – JavaForAndroid 2013-03-27 14:58:15