我是 Android 新手,我才 7 天前才开始。我遇到了这种类型的错误,并且还参考了同一论坛中的大部分主题,询问了类似的问题,但没有得到解决方法。
这是我的代码:
class CreateNewCustomer extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(MainActivity4.this);
pDialog.setMessage("Creating Customer..");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
@Override
protected String doInBackground(String...args) {
String fname = inputFName.getText().toString();
String lname = inputLName.getText().toString();
String phone = inputPhone.getText().toString();
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("fname", fname));
params.add(new BasicNameValuePair("lname", lname));
params.add(new BasicNameValuePair("phone", phone));
JSONObject json = jsonParser.makeHttpRequest(url_create_customer,
"POST", params);
Log.d("Create Response", json.toString());
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
Intent i = new Intent(getApplicationContext(),MainActivity5.class );
startActivity(i);
finish();
} else {
// This is the Else part
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String file_url) {
pDialog.dismiss();
}
}