0
我使用JSON
从用户登录时从MySQL数据库检索详细信息(fname,email,bikeno,mobileno)。除手机号码外,所有详细信息都将被删除。如何使用Json在Android中从Mysql检索移动号码
我的代码是:
progressBar = new ProgressDialog(v.getContext());
progressBar.setCancelable(true);
progressBar.setMessage("Logging You in");
progressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressBar.show();
StringRequest stringRequest = new StringRequest(Request.Method.POST, login_url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONArray jsonArray = new JSONArray(response);
JSONObject jsonObject = jsonArray.getJSONObject(0);
JSONObject jsonObject1= jsonArray.getJSONObject(0);
String code = jsonObject.getString("code");
if (code.equals("login_failed")) {
builder.setTitle("Login Error");
displayAlert(jsonObject.getString("message"));
} else {
Intent intent = new Intent(MainActivity.this, Home.class);
Bundle bundle = new Bundle();
bundle.putString("email1", jsonObject.getString("email"));
bundle.putString("bikeno1", jsonObject.getString("bikeno"));
bundle.putString("fname", jsonObject.getString("fname"));
bundle.putString("mobileno", jsonObject.getString("mobileno"));
intent.putExtras(bundle);
startActivity(intent);
finish();
}
} catch(Exception e){
}
}
}
});
我的问题是如何获得的手机号码,以及如何发送值到另一个活动?
是你的移动没有在你的JSON响应。 –
否bro。它显示记录你,但它不记录当我评论这行“bundle.putString(”mobileno“,jsonObject.getString(”mobileno“));”那么它能够登录到应用程序 –
在'response'中显示'JSON'。 –