Java 如何使用android登录数据库中的用户信息
私有void登录函数(){ Map params=新的HashMap() //Toast.makeText(getApplicationContext(),“欢迎用户:)stat=“+stat,Toast.LENGTH_SHORT).show() //Toast.makeText(getApplicationContext(),“我们找到了数据”,Toast.LENGTH_SHORT.show() //作者:哈泽姆·艾哈迈德>Java 如何使用android登录数据库中的用户信息,java,android,Java,Android,私有void登录函数(){ Map params=新的HashMap() //Toast.makeText(getApplicationContext(),“欢迎用户:)stat=“+stat,Toast.LENGTH_SHORT).show() //Toast.makeText(getApplicationContext(),“我们找到了数据”,Toast.LENGTH_SHORT.show() //作者:哈泽姆·艾哈迈德> 谢谢你的代码。你的问题到底是什么?请阅读和回答你的问题,以解决你的代
谢谢你的代码。你的问题到底是什么?请阅读和回答你的问题,以解决你的代码块的格式问题,包括所有需要的调试信息和你面临的问题的描述(你的问题的标题不是很有帮助)以及所需的结果。欢迎使用堆栈溢出!
RequestQueue rq = Volley.newRequestQueue(this);
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest
(Request.Method.GET, "http://10.0.2.2/CPanelNewsApp/Usercheck.php?email="+edemail.getText().toString()+"&&"+"password="+edpass.getText().toString(),
null,new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONArray jsonArray = response.getJSONArray("dishs");
String stat = jsonArray.getJSONObject(0).get("Stat").toString();
if(stat.matches("1")){
//receive user data from database;;;
userId = (jsonArray.getJSONObject(0).get("id").toString());
userName = (jsonArray.getJSONObject(0).get("name").toString());
userPhone = (jsonArray.getJSONObject(0).get("email").toString());
userEmail = (jsonArray.getJSONObject(0).get("phone").toString());
userPassword = (jsonArray.getJSONObject(0).get("password").toString());
//send user data to EditData.java;;;
Intent intent = new Intent(MainActivity.this,ViewCats.class);
intent.putExtra("userId",userId);
intent.putExtra("userName",userName);
intent.putExtra("userPhone",userPhone);
intent.putExtra("userEmail",userEmail);
intent.putExtra("userPassword",userPassword);
startActivity(intent);
}else{
Toast.makeText(getApplicationContext(),"No User !!! ",Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO: Handle error
Toast.makeText(getApplicationContext(),"Error Response 102",Toast.LENGTH_SHORT).show();
}
}