I have MainActivity.class
which is basically grid view that contains all products. When user clicks on any of these products, then it will take him to the detail page where products details are listed.
I could able to see response object as a string and need to pass this string to the ProductDetailActivity.class
, I have put a break point in ProductDetailActivity.class
but it never comes there. I am not sure if I am missing something or doing something wrong.
MainActivity.class
final String URL = ".../productDetail.php";
StringRequest postRequest = new StringRequest(Request.Method.POST, URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
// response string received successfully and displayed on the console.
VolleyLog.v("Response:%n %s", response);
Intent intent = new Intent(MainActivity.this,ProductDetailActivity.class);
intent.putExtra("jsonArray", response);
MainActivity.this.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
}
}
) {
@Override
protected Map<String, String> getParams()
{
Map<String, String> params = new HashMap<>();
params.put("id", records.get(position).getId());
return params;
}
};
CustomVolleyRequest.getInstance(this).getRequestQueue().add(postRequest);
ProductDetailActivity.class
public class ProductDetailActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.productdetail);
// break point placed in the following line, but never hit!
String jsonArray = getIntent().getStringExtra("jsonArray");
}
}
Update:
After I debug it carefully, MainActivity.this.startActivity(intent); that line of code gives me the following error:
Unable to find the explicit activity