Think Different
[AsyncTask] the task has already been executed 본문
Problem
- AsyncTask를 상속받아 클래스를 작성
- 해당 클래스의 인스턴스를 받아 외부통신을 시도
- "the task has already been executed"라는 오류로그와 함께 강제종료
Solution
- AsyncTask를 상속받아 작성된 클래스의 한 인스턴스는 한번만 실행가능
- 해당 클래스를 사용할 때마다 새로운 인스턴스를 생성하여 사용
Example
public class Network extends AsyncTask { //.. } public class AsyncTaskTest { public void getData() { String data = new Network().execute().get(); } }
Reference
- http://stackoverflow.com/questions/6373826/execute-asynctask-several-times
'OS > Android' 카테고리의 다른 글
레이아웃 비율 조정을 위한 weightSum 속성 (0) | 2014.09.17 |
---|---|
[include] 레이아웃 구성할 때 다른 레이아웃(XML)을 삽입하기 (0) | 2014.09.17 |
[TextView] android.content.res.Resources$NotFoundException (0) | 2014.09.16 |
call to OpenGL ES API with no current context (logged once per thread) (0) | 2013.09.21 |
안드로이드 기기에 음악파일 넣기 (0) | 2013.03.03 |