我有这段代码:
public void onClick(View v) {
switch (v.getId()) {
case R.id.bRegister:
dialog.show(Main.this, "Loading..", "", true, true);
RequestThread requestThread = new RequestThread();
requestThread.start();
break;
}
}
String Response = "";
class RequestThread extends Thread {
public void run() {
String NAME = name.getText().toString();
String PHONE = phone.getText().toString();
String url = baseUrl + "creatdriver.php?name=" + NAME + "&phone="
+ PHONE + "&latitude=23.234541" + "&longitude=90.123241";
if (HTTPmanage.isConnected(getApplicationContext())) {
Response = HTTPmanage.httpRetrieve(url);
} else {
Response = "Net Connection Unavailable";
}
handler.sendEmptyMessage(0);
}
}
Handler handler = new Handler() {
public void handleMessage(android.os.Message msg) {
dialog.dismiss();
Toast.makeText(getApplicationContext(), Response, Toast.LENGTH_LONG)
.show();
}
};
通过这段代码,我将一些数据插入MySQL.Everything工作正常但是当进度对话框完成时强制关闭并且有NULL POINTER异常,但我无法弄清楚我在哪里犯了错误?