title: popBackStack() not working when going back from Activity 2 Fragment to Activity 1 Fragment
body: <p>I have 2 Activity -  MainActivity and MainActivity2 .</p>
  
  <p>MainActivity has 2 fragments 
  MainActivity2 has 1 fragment</p>
  
  <p>So i pass data from  MainActivity_Frag_one to MainActivity_Frag_two. 
  <strong>When i click device back button and the blue button in MainActivity_Frag_two , it works well by going back to MainActivity_Frag_one.</strong> </p>
  
  <p>After that, I pass data from MainActivity_Frag_two to MainActivity2_Frag_one using intent</p>
  
  <p><strong>When i click device back button it works well by going back to MainActivity_Frag_two but the blue button is not working (no effect when clicked, also no error shows).</strong> </p>
  
  <p>May i know which part has gone wrong? </p>
  
  <p><a href="https://i.stack.imgur.com/TFlqP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TFlqP.jpg" alt="enter image description here"></a>
  <strong>MainActivity.java</strong></p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      FragmentManager manager=getSupportFragmentManager();
      FragmentTransaction transaction=manager.beginTransaction();
      MainActivity_Frag_one MainActivity_Frag_one=new MainActivity_Frag_one();
      transaction.add(R.id.activity_one_container,MainActivity_Frag_one);
      transaction.commit();
  }
  </code></pre>
  
  <p><strong>MainActivity_Frag_one.java</strong></p>
  
  <pre><code>public class MainActivity_Frag_one extends Fragment {
  
  EditText get_text;
  Button get_button;
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.fragment_main_activity__frag_one,container,false);
  
      get_text=(EditText)rootView.findViewById(R.id.input_name);
      get_button=(Button)rootView.findViewById(R.id.submit_button);
  
      get_button.setOnClickListener(new View.OnClickListener(){
  
          public void onClick(View v){
  
  
              FragmentManager manager=getFragmentManager();
              FragmentTransaction transaction=manager.beginTransaction();
              Bundle bundle=new Bundle();
              bundle.putString("message", get_text.getText().toString());
              MainActivity_Frag_two fragobj=new MainActivity_Frag_two();
              fragobj.setArguments(bundle);
              transaction.replace(R.id.activity_one_container,fragobj);
              transaction.addToBackStack("zzz");
              transaction.commit();
  
          }
  
      });
  
      return rootView;
  }
  }
  </code></pre>
  
  <p><strong>MainActivity_Frag_two.java</strong></p>
  
  <pre><code>public class MainActivity_Frag_two extends Fragment {
  
  ImageView get_button;
  Button get_to_second_activity;
  String strtext;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.fragment_main_activity__frag_two,container,false);
      TextView display_text=(TextView)rootView.findViewById(R.id.display_text);
      strtext=getArguments().getString("message");
      display_text.setText(strtext);
  
      get_button=(ImageView)rootView.findViewById(R.id.back_button);
      get_button.setOnClickListener(new View.OnClickListener(){
  
          public void onClick(View v){
  
              getFragmentManager().popBackStack();
  
          }
      });
  
      get_to_second_activity=(Button)rootView.findViewById(R.id.to_second_activity);
      get_to_second_activity.setOnClickListener(new View.OnClickListener(){
  
          public void onClick(View v){
              Intent intent = new Intent(getActivity(),MainActivity2.class);
              intent.putExtra("Check","data from mainactivity_frag_two is : "+strtext);
              startActivity(intent);
  
              FragmentManager manager=getFragmentManager();
              FragmentTransaction transaction=manager.beginTransaction();
              transaction.addToBackStack("");
              transaction.commit();
          }
      });
      return rootView;
  }
  }
  </code></pre>
  
  <p><strong>MainActivity2.java</strong></p>
  
  <pre><code>public class MainActivity2 extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main2);
  
      FragmentManager manager=getSupportFragmentManager();
      FragmentTransaction transaction=manager.beginTransaction();
      MainActivity2_Frag_one MainActivity2_Frag_one=new MainActivity2_Frag_one();
      transaction.add(R.id.activity_two_container,MainActivity2_Frag_one);
      transaction.commit();
  
  }
  }
  </code></pre>
  
  <p><strong>MainActivity2_Frag_one.java</strong></p>
  
  <pre><code>public class MainActivity2_Frag_one extends Fragment {
  TextView get_display;
  ImageView get_button;
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.fragment_main_activity2__frag_one,container,false);
  
      get_display=(TextView)rootView.findViewById(R.id.display);
      String data1=getActivity().getIntent().getExtras().getString("Check");
      get_display.setText(data1);
  
      get_button=(ImageView)rootView.findViewById(R.id.back_to_previous_frag);
      get_button.setOnClickListener(new View.OnClickListener(){
  
          public void onClick(View v){
  
              getFragmentManager().popBackStack();
  
          }
      });
      return rootView;
  }
  }
  </code></pre>