안녕하세요. 


Fragment 안에서 


AsyncTask 로 doInBackground 에서 getActivity()를 실행하면


항상은 아닌데, 종종 null 값이 떨어집니다.


Fragment 이동시 소스 코드입니다.

TestFragment fragment = TestFragment.getInstance();

        FragmentTransaction ft = getFragmentManager().beginTransaction();

        Fragment testStudy = getFragmentManager().findFragmentByTag("testStudy");

        if (testStudy != null) {

        Log.d("testStudy", "not null");

            ft.remove(testStudy);

        }

        ft.replace(R.id.content_frame, fragment, "testStudy");

        ft.setTransition(FragmentTransaction.TRANSIT_NONE);

        ft.commit();

다른 Fragment로 10~20번 정도 왔다갔다 하면 null 발생을 하더라고요..


혹시 해결방법을 아시는 분 답변 좀 부탁드립니다.


주변 사람들 한테 물어보니 Fragment에서 getAcitivity()를 사용 했을 때 간혹 null 값이 나온다는 분이 꽤 있으신 것 같은데요.


답변 주시면 여러 사람한테 도움이 될 것 같습니다.


감사합니다.