【发布时间】:2015-11-17 13:21:06
【问题描述】:
得到错误,我不知道为什么我一直在看它几个小时,我觉得这是我缺少的一些基本的东西 有人可以看看它可能是什么吗?
public class ServerRequests {
ProgressDialog progressDialog;
public static final int CONNECTION_TIMEOUT = 1000 * 15;
public static final String SERVER_ADDRESS = "http://eocribin.netne.net";
我觉得我在上面的部分中将主机标记为稍后用作变量但它只将其注册为路径
public ServerRequests(Context context) {
progressDialog = new ProgressDialog(context);
progressDialog.setCancelable(false);
progressDialog.setTitle("Processing...");
progressDialog.setMessage("Please wait...");
}
public void storeUserDataInBackground(User user,
GetUserCallback userCallBack) {
progressDialog.show();
new StoreUserDataAsyncTask(user, userCallBack).execute();
}
public void fetchUserDataAsyncTask(User user, GetUserCallback userCallBack) {
progressDialog.show();
new fetchUserDataAsyncTask(user, userCallBack).execute();
}
/**
* parameter sent to task upon execution progress published during
* background computation result of the background computation
*/
public class StoreUserDataAsyncTask extends AsyncTask<Void, Void, Void> {
User user;
GetUserCallback userCallBack;
public StoreUserDataAsyncTask(User user, GetUserCallback userCallBack) {
this.user = user;
this.userCallBack = userCallBack;
}
@Override
protected Void doInBackground(Void... params) {
ArrayList<NameValuePair> dataToSend = new ArrayList<>();
dataToSend.add(new BasicNameValuePair("name", user.name));
dataToSend.add(new BasicNameValuePair("username", user.username));
dataToSend.add(new BasicNameValuePair("password", user.password));
dataToSend.add(new BasicNameValuePair("age", user.age + ""));
HttpParams httpRequestParams = getHttpRequestParams();
HttpClient client = new DefaultHttpClient(httpRequestParams);
HttpPost post = new HttpPost(SERVER_ADDRESS
+ "/Register.php");
try {
post.setEntity(new UrlEncodedFormEntity(dataToSend));
client.execute(post);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
【问题讨论】:
-
我认为你缺少来自
path=eocribin.netne.net/FetchUserData.php的“http://” -
使用我认为我已经拥有它但显然不是谢谢
-
太棒了!我会把它作为答案发布
标签: android server database-connection host