안드로이드 개발 질문/답변
(글 수 45,052)
제가
new AlertDialog.Builder(getApplicationContext() );
이렇게 사용해서 계속 오류가 났던건지 모르고 삽질만 2시간했었는데요
궁금한게 있습니다
Toast.makeText(Context context)
AlertDialog.Builder(Context context);
둘다 Context 객체를 받는데 getApplicationContext() 이게 Context 객체를 반환하는데
토스트는 사용가능 하고 왜 다이얼로그는 오류가 왜 나는지 궁금합니다
2010.09.04 22:03:47
테스트를 해보지 않아서 잘 모르겠지만 제 기역으로 다이얼로그에서 필요한 context 는 Activity의 Context가 필요해서 그런거 같은데.. 함 확인해 보세요 ㅎㅎ
2010.09.04 22:42:55
the Application context. This context will live as long as your application is alive and does not depend on the activities life cycle. If you plan on keeping long-lived objects that need a context, remember the application object. You can obtain it easily by calling Context.getApplicationContext() or Activity.getApplication().