I have activity A which contain fragment, inside that I call a API by Volley and all is ok. Then I go to activity B, do an other API and then com back to activity A by:
Intent setIntent = new Intent(this, HomeActivity.class);
setIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK
| Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(setIntent);
Then inside this A activity automatically call the API by Volley again, server return response and my Request class even can log this response, but Volley never return that response to call back method to activity.
I think maybe the activity which have been call by above Intent have some thing difference so Volley cannot return response to the activity. When I turn the screen off and on again, the response now come to the activity.
Did anyone met this issue before can help. Thank you very much.
This happen because in my activity B, I cancelled all the Volley request:
@Override
protected void onStop() {
super.onStop();
// Cancel all request
VolleySingleton.getInstance()
.cancelPendingRequests(VolleySingleton.TAG);
}
Sometime onStop() of activity B is run after the onResume() of activity A so it will cancel all the request that A had made.