1
A
回答
4
您使用擴展AsynTask的類... 請參閱此link。
在你的doInBackground()裏面調用你的插入方法。
更多的解釋:
烏爾活動中創建一個內部類InsertTask,如:
private class InsertTask extends AsyncTask<String, Void, Boolean> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Boolean doInBackground(String... params) {
Boolean success = false;
try {
//place insert code here
success = true;
} catch (Exception e) {
if(e.getMessage()!=null)
e.printStackTrace();
}
return success;
}
@Override
protected void onPostExecute(Boolean success) {
super.onPostExecute(success);
}
}
在我們共同的onCreate()給:
new InsertTask.execute(); //this calls the doInBackground method of InsertTask
通過這樣做,當烏爾活動被調用,doInBackground()內部寫入的內容將通過插入ur值來運行。
+0
thanx很多它適用於我的應用程序...真棒.. – 2011-03-07 11:34:05
+0
總是歡迎.. – Mathew 2011-03-07 11:41:48
相關問題
- 1. 運行我的後臺應用程序,當我在Android中
- 2. 當應用程序進入後臺時運行後臺線程
- 3. 我如何讓我的Android應用程序在後臺運行
- 4. 當應用程序未運行時在後臺運行SyncAdapter
- 5. 如何在Android中在後臺運行我的應用程序?
- 6. 如何在後臺運行我的Windows Phone應用程序?
- 7. 如何在後臺運行我的GPS應用程序?
- 8. 我們如何在iOS7的後臺運行應用程序
- 9. 如何讓我的應用程序在後臺運行?
- 10. 如何讓我的應用程序在後臺運行
- 11. 當它運行後臺狀態時,是否可以從我的應用程序運行應用程序?
- 12. 如何更新後臺運行的應用程序的數據
- 13. 在後臺運行的應用程序
- 14. 運行我的應用程序時,SqlAdapter在我運行存儲過程時不返回任何數據
- 15. 當我運行的Web應用程序
- 16. 當我的應用程序沒有在後臺運行時停止服務
- 17. 當我在運行iPhone應用程序
- 18. 當應用程序轉到後臺時如何運行NSThread
- 19. 當應用程序進入後臺時運行MPMoviePlayer
- 20. 如何在應用程序的後臺運行計時器?
- 21. 在後臺運行我的應用程序
- 22. 避免在後臺運行我的Android應用程序
- 23. 當我的應用程序未運行時,如何處理FCM?
- 24. 我如何知道我的Android應用程序是否在後臺運行?
- 25. 我的應用程序如何在後臺運行時訪問觸摸事件?
- 26. 如何取消後臺運行線程在我的iPhone應用程序
- 27. 當我單擊運行時,Eclipse不運行Android應用程序
- 28. 如何知道我的應用程序在後臺或前臺運行?
- 29. 當我的應用程序從後臺運行返回時,UIButton消失
- 30. 當我運行應用程序時,我的TableView崩潰了應用程序
當應用程序正常工作時,您可以使用將在後臺填充數據庫的任務。 – Mudassir 2011-03-07 10:19:41