I know this problem was asked before, but I could not find any useful answer for my problem. Imagine an application that uses the Google.Volley library for a RESTful api. When the application launches MainActivity it shows dialogFragment (Download) and when the answer comes, I would like to commit the FragmentTransaction and show the data to the user like this.
JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, url, parameterJson, new Response.Listener<JSONObject>()
{
@Override
public void onResponse(JSONObject response)
{
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.container, MainScreenFragment.newInstance(gaObservers))
.commit();
}
}, new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error)
{
}
});
So what's best here please? Any help would be appreciated. PS: I read Fragment Reports and Activity Loss Message , but I feel that I canβt avoid asynchronous commit. Thanks you