안드로이드 개발 질문/답변
(글 수 45,052)
public abstract class AbstractEventInfo implements Serializable, SoapParameter.SoapMethod
{
protected Context mContext;
..........
public void AbstractEventInfo(Context context ){
mContext = context;
}
....
private class EventTypeCode
{
private static final int EVENT_TYPE_NONE = 0;
......
protected String getString(int code)
{
Resources res = mContext.getResources();
......
switch(code)
{
case EVENT_TYPE_NONE:
return res.getString(R.string.event_none);
....
}
}
}
}
현재 클래스가 Activity를 사용하지 않아서 Context를 사용하여 resource (string값) 를 얻어오려합니다.
위 소스와 같이 구현했는데 실행을 시켜보면
Resources res = mContext.getResources(); 에서 NullPointerException이 발생합니다.
Context를 불러오는게 이상한건가요??
답변주시면 감사하겠습니다.



