我的应用程序中有 FB、Google 和正常登录。当我使用 FB 或 google 登录时,一切都很好,但是每当我从应用程序注册并立即登录时,我没有在 CartActivity RecyclerView 中获取数据,但数据显示在邮递员中或浏览器。当我卸载应用程序并重新安装数据时,再次开始显示旧的登录凭据。购物车活动:
try {
StringRequest stringRequest = new StringRequest(Request.Method.GET, url2,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
pd.dismiss();
// Toast.makeText(CartActivity.this, "responce"+response.toString(), Toast.LENGTH_SHORT).show();
System.out.println("Response is : " + response);
try {
JSONObject jsono = new JSONObject(response);
if (jsono.getString("status").equals("success")) {
JSONArray jarray = jsono.getJSONArray("data");
for (int i = 0; i < jarray.length(); i++) {
JSONObject object = jarray.getJSONObject(i);
String total = object.getString("cart_total");
jarray = jsono.getJSONArray("data");
JSONArray jarray1 = object.getJSONArray("product_description");
for (int j = 0; j < jarray1.length(); j++) {
JSONObject object1 = jarray1.getJSONObject(j);
JSONArray jarray2 = object1.getJSONArray("data");
for (int k = 0; k < jarray2.length(); k++) {
JSONObject object2 = jarray2.getJSONObject(k);
String Name = object2.getString("product_name");
String Image = object2.getString("product_image");
String Price = object2.getString("product_price");
String Qty = object2.getString("product_qty");
String sku = object2.getString("product_sku");
String ProId = object2.getString("product_id");
System.out.println("VALUES: " + Name + "price" + Price + "qty" + Qty + sku + "proid" + ProId);
}
}
}
rccart.setAdapter(cartAdapter);
cartAdapter.notifyDataSetChanged();
} else {
Toast.makeText(getApplicationContext(), "Something went wrong...", Toast.LENGTH_SHORT).show();
}
} catch (Exception ex) {
System.out.println("EXCPTION IN SUCCESS REQUEST : " + ex.toString());
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
pd.dismiss();
System.out.println("ERROR IN REQUEST : " + error.getMessage());
}
})
{
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
return params;
}
};
stringRequest.setRetryPolicy(new DefaultRetryPolicy(
90000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
RequestQueue requestQueue = Volley.newRequestQueue(CartActivity.this);
requestQueue.add(stringRequest);
pd = new ProgressDialog(CartActivity.this);
pd.setMessage("Loading...");
pd.show();
} catch (Exception ex) {
}
}