基本上我在数据库端设置了一些成员,我还做了一个注册表单,它将数据发布到数据库,但我遇到的问题是我的程序不会启动活动。当我注释掉它运行的httppost部分时,所以我相信我的问题与PHP文件有关,但是已经发布了我已经完成的java代码。在另一个问题中,我将发布PHP代码。
try
{
httpclient = new default HttpClient();
httppost = new HttpPost("");
nameValuePair = new arrayList < NameValuePair > (1);
nameValuePair . add(new BasicNameValuePair("email", email . getText() . toString() . trim()));
nameValuePair . add(new BasicNameValuePair("password", password . getText() . toString() . trim()));
httppost . setEntity(new UrlEncodedF or mEntity(nameValuePair));
response = httpclient . execute(httppost);
ResponseHandler < String > responseHandler = new BasicResponseHandler();
final Stringresponse = httpclient . execute(httppost, responseHandler);
loginErrorMsg . setText("" + response);
if(response . equalsIgnorecase ("Log in Successful"))
{
startActivity(new Intent(LoginActivity . this, HomescreenActivity . class ));
}
}
catch(Exceptione)
{
e.printStackTrace();
}
答案 0 :(得分:0)
答案 1 :(得分:0)
您是否请求过互联网权限?
<uses-permission android:name="android.permission.INTERNET" />
答案 2 :(得分:0)
nameValuePair = new ArrayList<NameValuePair>(1);
nameValuePair.add(new BasicNameValuePair("email", email.getText().toString().trim()));
nameValuePair.add(new BasicNameValuePair("password", password.getText().toString().trim()));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePair));
response = httpclient.execute(httppost);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
final HttpResponse responsed = httpclient.execute(httppost, responseHandler);
final String response= EntityUtils.toString(responsed .getEntity());
loginErrorMsg.setText(""+response);
if(response.equalsIgnoreCase("Log in Successful"))
startActivity(new Intent(LoginActivity.this, HomescreenActivity.class));
}
catch(Exception e){
e.printStackTrace();
}