안드로이드 개발 질문/답변
(글 수 45,052)
빌드랑 아무런문제가 없는데 이런에러가 납니다.
java.lang.NullPointerException
at com.android.ddmlib.Client.sendAndConsume(Client.java:572)
at com.android.ddmlib.HandleHello.sendHELO(HandleHello.java:142)
at com.android.ddmlib.HandleHello.sendHelloCommands(HandleHello.java:65)
at com.android.ddmlib.Client.getJdwpPacket(Client.java:671)
at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:317)
at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)
도저히 어디서... 뭐가틀렸는지를 찾을수가없어서 도움을 요청해봅니다.
아래는 소스 원문 입니다.
main.java 입니다.
PrefActivityFromResource.java 입니다.
java.lang.NullPointerException
at com.android.ddmlib.Client.sendAndConsume(Client.java:572)
at com.android.ddmlib.HandleHello.sendHELO(HandleHello.java:142)
at com.android.ddmlib.HandleHello.sendHelloCommands(HandleHello.java:65)
at com.android.ddmlib.Client.getJdwpPacket(Client.java:671)
at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:317)
at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)
도저히 어디서... 뭐가틀렸는지를 찾을수가없어서 도움을 요청해봅니다.
아래는 소스 원문 입니다.
main.java 입니다.
package catholic.schedule;
import android.app.*; import android.os.*; import android.preference.*; import android.accessibilityservice.*; import android.accounts.*; import android.bluetooth.*; import android.content.*; import android.database.*; import android.gesture.*; import android.graphics.*; import android.location.*; import android.speech.*; import android.telephony.*; import android.util.*; import android.view.*; import android.widget.*;
public class main extends Activity {
/** Called when the activity is first created. */
public static final int ID_MENU_PREFERENCES_XML = Menu.FIRST+1;
public static final int ID_MENU_PREFERENCES_INTENT = Menu.FIRST+2;
SharedPreferences defaultSharedPref;
TextView tvImportance_date;
TextView tvAdd_delete_date;
TextView tvSet_d_day;
TextView tvRemember_day;
TextView tvSetting;
TextView tvexcept_call;
TextView tvSMS_Setting;
TextView tvTalling;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// addPreferencesFromResource(R.xml.settings);
tvImportance_date = (TextView)findViewById(R.id.Importance_date);
tvAdd_delete_date = (TextView)findViewById(R.id.add_delete_date);
tvSet_d_day = (TextView)findViewById(R.id.set_d_day);
tvRemember_day = (TextView)findViewById(R.id.remember_day);
tvSetting = (TextView)findViewById(R.id.setting);
tvexcept_call = (TextView)findViewById(R.id.except_call);
tvSMS_Setting = (TextView)findViewById(R.id.SMS_Setting);
tvTalling = (TextView)findViewById(R.id.talling);
// date/date/catholic.schedule/shared_prefs/catholic.schedule_preferences.xml파일과
// 연결되는 SharedPreferences 인터페이스 얻기.
// 해당파일이 없다면 안드로이드가 자동으로 생성
defaultSharedPref = PreferenceManager.getDefaultSharedPreferences(this);
}
protected void onResume(){
super.onResume();
// App의 DefaultSharedPreference 파일로 부터 환경 설정값 얻기
boolean isOptionalMsgShown = defaultSharedPref.getBoolean("Importance_date",false);
String strOptionalMsg = defaultSharedPref.getString("AdditionalMsg","<None>");
String strColor = defaultSharedPref.getString("TextColor","FFFFFFFF");
String strRingtone = defaultSharedPref.getString("Rington","<None Selected>");
// Activity의 child view들의 환경 설정값 복원
tvImportance_date.setTextColor((int)Long.parseLong(strColor,16));
tvAdd_delete_date.setTextColor((int)Long.parseLong(strColor,16));
tvSet_d_day.setTextColor((int)Long.parseLong(strColor,16));
tvRemember_day.setTextColor((int)Long.parseLong(strColor,16));
tvSetting.setTextColor((int)Long.parseLong(strColor,16));
tvexcept_call.setTextColor((int)Long.parseLong(strColor,16));
tvSMS_Setting.setTextColor((int)Long.parseLong(strColor,16));
tvTalling.setTextColor((int)Long.parseLong(strColor,16));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(Menu.NONE, ID_MENU_PREFERENCES_XML, Menu.NONE, "환경설정(XML 리소스)");
menu.add(Menu.NONE, ID_MENU_PREFERENCES_INTENT, Menu.NONE, "환경설정(Intent)");
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case ID_MENU_PREFERENCES_XML:
// Intent를 사용해 다른 Activity를 실행 (Intent 관련 포스트에서 자세히 다룰 예정
startActivity(new Intent(this, PrefActivityFromResource.class));
return true;
case ID_MENU_PREFERENCES_INTENT:
startActivity(new Intent(this, PrefActivityFromResource.class));
return true;
default:
finish();
return super.onOptionsItemSelected(item);
}
}
}
PrefActivityFromResource.java 입니다.
package catholic.schedule;
import android.app.*; import android.os.*; import android.preference.*; import android.accessibilityservice.*; import android.accounts.*; import android.bluetooth.*; import android.content.*; import android.database.*; import android.gesture.*; import android.graphics.*; import android.location.*; import android.speech.*; import android.telephony.*; import android.util.*; import android.view.*; import android.widget.*;
public class main extends Activity {
/** Called when the activity is first created. */
public static final int ID_MENU_PREFERENCES_XML = Menu.FIRST+1;
public static final int ID_MENU_PREFERENCES_INTENT = Menu.FIRST+2;
SharedPreferences defaultSharedPref;
TextView tvImportance_date;
TextView tvAdd_delete_date;
TextView tvSet_d_day;
TextView tvRemember_day;
TextView tvSetting;
TextView tvexcept_call;
TextView tvSMS_Setting;
TextView tvTalling;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// addPreferencesFromResource(R.xml.settings);
tvImportance_date = (TextView)findViewById(R.id.Importance_date);
tvAdd_delete_date = (TextView)findViewById(R.id.add_delete_date);
tvSet_d_day = (TextView)findViewById(R.id.set_d_day);
tvRemember_day = (TextView)findViewById(R.id.remember_day);
tvSetting = (TextView)findViewById(R.id.setting);
tvexcept_call = (TextView)findViewById(R.id.except_call);
tvSMS_Setting = (TextView)findViewById(R.id.SMS_Setting);
tvTalling = (TextView)findViewById(R.id.talling);
// date/date/catholic.schedule/shared_prefs/catholic.schedule_preferences.xml파일과
// 연결되는 SharedPreferences 인터페이스 얻기.
// 해당파일이 없다면 안드로이드가 자동으로 생성
defaultSharedPref = PreferenceManager.getDefaultSharedPreferences(this);
}
protected void onResume(){
super.onResume();
// App의 DefaultSharedPreference 파일로 부터 환경 설정값 얻기
boolean isOptionalMsgShown = defaultSharedPref.getBoolean("Importance_date",false);
String strOptionalMsg = defaultSharedPref.getString("AdditionalMsg","<None>");
String strColor = defaultSharedPref.getString("TextColor","FFFFFFFF");
String strRingtone = defaultSharedPref.getString("Rington","<None Selected>");
// Activity의 child view들의 환경 설정값 복원
tvImportance_date.setTextColor((int)Long.parseLong(strColor,16));
tvAdd_delete_date.setTextColor((int)Long.parseLong(strColor,16));
tvSet_d_day.setTextColor((int)Long.parseLong(strColor,16));
tvRemember_day.setTextColor((int)Long.parseLong(strColor,16));
tvSetting.setTextColor((int)Long.parseLong(strColor,16));
tvexcept_call.setTextColor((int)Long.parseLong(strColor,16));
tvSMS_Setting.setTextColor((int)Long.parseLong(strColor,16));
tvTalling.setTextColor((int)Long.parseLong(strColor,16));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(Menu.NONE, ID_MENU_PREFERENCES_XML, Menu.NONE, "환경설정(XML 리소스)");
menu.add(Menu.NONE, ID_MENU_PREFERENCES_INTENT, Menu.NONE, "환경설정(Intent)");
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case ID_MENU_PREFERENCES_XML:
// Intent를 사용해 다른 Activity를 실행 (Intent 관련 포스트에서 자세히 다룰 예정
startActivity(new Intent(this, PrefActivityFromResource.class));
return true;
case ID_MENU_PREFERENCES_INTENT:
startActivity(new Intent(this, PrefActivityFromResource.class));
return true;
default:
finish();
return super.onOptionsItemSelected(item);
}
}
}



