Replace fragment in another Activity Android -


I have two fractal activites. I can go from activity (A) to activity (B), and various pieces After the change, (B) has a home button that should return the first piece of activity (A). My code is:

  btnHome.setOnClickListener (New View.OnClickListener () {@Override Public Zero onClick (see arg0) {Finish}; MainActivity.fragmentManager .beginTransaction () .replace (R .id.content_frame, new first restriction ()). AddToBackStack (null) .commit ();}});   

Which is fragmentManager :

  FragmentManager fragmentManager = getSupportFragmentManager ();   

In MainActivity, but I get an error below:

  java.lang.IllegalStateException: onSaveInstanceState, this action can not be executed < / code>  

How can I handle it?

"itemprop =" text ">

OK, I got his place from commitAllowingStateLoss () Committed with () . So it became like this:

  MainActivity.fragmentManager .beginTransaction () .replace (R.id.content_frame, new firstFragment ()) .addToBackStack (zero) .commitAllowingStateLoss ();    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -