Why is onResume () called in hidden fragments?

My application shows a lot of images on the main screen. The user can view additional product information by clicking on the image. The main screen fragment is hidden, and the product part fragment becomes visible. By clicking on the back button, a fragment of the main screen will again become visible.

The fragment transaction is implemented as follows:

    @Override
public void showProduct(Product p, boolean isParentTabbed) {
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction transaction = fm.beginTransaction();

    // the new fragment
    Fragment mFragment = new ProductDetailFragment(p,isParentTabbed);

    //hide main screen fragment and add product detail fragment
    transaction.hide(currentlyOpenedFragment);
    transaction.add(android.R.id.content,mFragment);

    //set new fragment as current "on top" fragment
    currentlyOpenedFragment = mFragment;

    //start animation
    transaction.setCustomAnimations(R.anim.slide_in_bottom, R.anim.slide_out_top);

    transaction.addToBackStack(null);
    transaction.commit();
}

, , ( share android) , "". - onResume ( ). , onResume :

    super.onResume();
    if(this.isHidden()){
        Log.d("tab","dont resume tab0fragment because it is hidden");
        return;
    }

, : onResume() , ?

+5
1

- . - . User navigates backwards or the fragment is removed/replaced. onDestroyView(), The fragment returns to the layout from the back stack,, .

+3

All Articles