0
인터넷 자원을 스레드로 가져 오는 중 오류가 발생합니다.스레드의 오류
은 내가 로그 캣이 오류가 발생합니다 :
09-04 21:05:32.916 1480-1493/abc.digicare.sms1 E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-78
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:121)
at android.widget.Toast$TN.<init>(Toast.java:317)
at android.widget.Toast.<init>(Toast.java:91)
at android.widget.Toast.makeText(Toast.java:233)
at abc.digicare.sms1.MyActivity$1.run(MyActivity.java:45)
at java.lang.Thread.run(Thread.java:856)
내 코드는 이것이다 : 버튼 클릭에서이 함수를 호출. 다른 클래스에서 호출
public void GetData(View v) {
Toast.makeText(getApplicationContext(), "first", Toast.LENGTH_SHORT).show();
p=ProgressDialog.show(getApplicationContext(),"Digicare","Wait . . .");
try {
Runnable myrun = new Runnable() {
@Override
public void run() {
String acc = "";
if (chckbx_cus.isChecked() && !(chckbx_ven.isChecked()) && !(chckbx_emp.isChecked())) {
acc = "cus";
} else if (chckbx_ven.isChecked() && !(chckbx_cus.isChecked()) && !(chckbx_emp.isChecked()))
Toast.makeText(getApplicationContext(), acc, Toast.LENGTH_SHORT).show();
final String facc = acc;
GetList GL = new GetList();
//Toast.makeText(getApplicationContext(),txt_ip.getText(),Toast.LENGTH_SHORT).show();
obj = GL.GetAccounts(getApplicationContext(), facc, "GetAccounts", "192.168.1.111");
mhandler.sendEmptyMessage(0);
}
};
Thread th = new Thread(myrun);
th.start();
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "from here " + e.toString(), Toast.LENGTH_LONG).show();
}
mhandler = new Handler() {
@Override
public void handleMessage(Message msg) {
p.dismiss();
}
};
}
함수는 당신이 백그라운드 스레드에서 토스트를 표시하려고하는 것으로 보인다 asp.net 웹 서비스