这是我的错误。
E/Volley: [272] BasicNetwork.performRequest: Unexpected response code 404 for http://192.168.0.102/line_app/includes/loginUser.php
com.android.volley.ClientError
com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:190)
com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:120)
com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:87)
GL_emulation: eglSurfaceAttrib not implemented
Failed to set EGL_SWAP_BEHAVIOR on surface 0xf3f9ee80, error=EGL_SUCCES
我的代码
MainActivity.java
package com.example.rahul.lineapp;
import android.app.ProgressDialog;
import android.content.Intent;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.NetworkError;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.ServerError;
import com.android.volley.TimeoutError;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.Volley;
import org.json.JSONException;
import org.json.JSONObject;
public class MainActivity extends AppCompatActivity {
TextInputLayout ltxtb1,ltxtb2;
Button lbtn1;
String email, password;
TextView ltxt1;
RequestQueue requestQueue;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("Login"); //set title of the activity
initialize(); //Initialize all the components present in the layout
requestQueue = Volley.newRequestQueue(MainActivity.this);//Creating the RequestQueue
//Login Button Clicked
lbtn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
email = ltxtb1.getEditText().getText().toString();
password = ltxtb2.getEditText().getText().toString();
if (validateUsername(email) && validatePassword(password)) { //email and Password Validation
final ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setTitle("Please Wait");
progressDialog.setMessage("Logging You In");
progressDialog.setCancelable(false);
progressDialog.show();
LoginRequest loginRequest = new LoginRequest(email, password, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.i("Login Response", response);
progressDialog.dismiss();
// Response from the server is in the form if a JSON, so we need a JSON Object
try {
JSONObject jsonObject = new JSONObject(response);
if (jsonObject.getBoolean("success")) {
Intent loginSuccess = new Intent(MainActivity.this, dash.class);
//Passing all received data from server to next activity
loginSuccess.putExtra("username", jsonObject.getString("username"));
loginSuccess.putExtra("email", jsonObject.getString("email"));
startActivity(loginSuccess);
finish();
} else {
if(jsonObject.getString("status").equals("INVALID"))
Toast.makeText(MainActivity.this, "User Not Found", Toast.LENGTH_SHORT).show();
else{
Toast.makeText(MainActivity.this, "Passwords Don't Match", Toast.LENGTH_SHORT).show();
}
}
}catch (JSONException e) {
e.printStackTrace();
Toast.makeText(MainActivity.this, "Bad Response From Server", Toast.LENGTH_SHORT).show();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
progressDialog.dismiss();
if (error instanceof ServerError)
Toast.makeText(MainActivity.this, "Server Error", Toast.LENGTH_SHORT).show();
else if (error instanceof TimeoutError)
Toast.makeText(MainActivity.this, "Connection Timed Out", Toast.LENGTH_SHORT).show();
else if (error instanceof NetworkError)
Toast.makeText(MainActivity.this, "Bad Network Connection", Toast.LENGTH_SHORT).show();
error.printStackTrace();
}
});
requestQueue.add(loginRequest);
}
}
});
//Don't Have An Account TextView Clicked
ltxt1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, SignupActivity.class);
startActivity(intent);
}
});
}
private void initialize() {
ltxtb1 = (TextInputLayout) findViewById(R.id.txtbx1);
ltxtb2 = (TextInputLayout) findViewById(R.id.txtbx2);
lbtn1 = (Button) findViewById(R.id.button1);
ltxt1 = (TextView) findViewById(R.id.txt2);
}
private boolean validateUsername(String string) {
//Validating the entered USERNAME
if (string.equals("")) {
ltxtb1.setError("Enter a Email");
return false;
} else if (string.length() > 50) {
ltxtb1.setError("Maximum 50 Characters");
return false;
} else if (string.length() < 6) {
ltxtb1.setError("Minimum 6 Characters");
return false;
}
ltxtb1.setErrorEnabled(false);
return true;
}
private boolean validatePassword(String string) {
//Validating the entered PASSWORD
if (string.equals("")) {
ltxtb2.setError("Enter Your Password");
return false;
} else if (string.length() > 32) {
ltxtb2.setError("Maximum 32 Characters");
return false;
} else if (string.length() < 8) {
ltxtb2.setError("Minimum 8 Characters");
return false;
}
ltxtb2.setErrorEnabled(false);
return true;
}
}
这是我的LoginRequest.java文件
LoginRequest.java
package com.example.rahul.lineapp;
import com.android.volley.AuthFailureError;
import com.android.volley.Response;
import com.android.volley.toolbox.StringRequest;
import java.util.HashMap;
import java.util.Map;
public class LoginRequest extends StringRequest {
private static final String ROOT_URL = "http://192.168.0.102/line_app/includes/";
public static final String LOGIN_URL = ROOT_URL+"loginUser.php";
private Map<String, String> parameters;
public LoginRequest(String email, String password, Response.Listener<String> listener, Response.ErrorListener errorListener) {
super(Method.POST, LOGIN_URL, listener, errorListener);
parameters = new HashMap<>();
parameters.put("email", email);
parameters.put("password", password);
}
@Override
protected Map<String, String> getParams() throws AuthFailureError {
return parameters;
}
}
运行&#39; MainActivity&#39;并输入登录详细信息,我得到&#34;服务器错误&#34;。 我无法理解究竟是什么错误。 我试图将我的应用程序连接到数据库。
这是我的应用程序的主要内容&#39;图像链接
提前感谢...
答案 0 :(得分:-1)
您需要将网络模式更改为GSM / WCDMA