title: Android App crashes every second time when i call fragment from activity?
body: <p>I have created a simple main fragment page with a button that calls the activity class layout and on reaching activty class ,that acitivity class call back fragment class layout on button click .
  Below is the simple fragment class with a simple button that calls activity class and it works without any issue. But once Acitiviy page is opened , on clicking button to go back to fragment layout ,it crash the app every second time i click that button. any help would be highly appreciated.</p>
  <p>with below error</p>
  <blockquote>
  <p>java.lang.IllegalArgumentException: No view found for id 0x7f0b007d
  (org.pjsip.pjsua2:id/container01) for fragment fragment_login{1bd38c1
  (5a612956-fc18-4272-8230-f79e71fed06a) id=0x7f0b007d}
  at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:875)
  at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
  at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
  at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
  at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
  at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
  at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
  at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
  at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
  at android.os.Handler.handleCallback(Handler.java:883)
  at android.os.Handler.dispatchMessage(Handler.java:100)
  at android.os.Looper.loop(Looper.java:237)
  at android.app.ActivityThread.main(ActivityThread.java:8107)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)</p>
  </blockquote>
  <pre><code>public class fragment_login extends Fragment  {
  
      // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
      private static final String ARG_PARAM1 = &quot;param1&quot;;
      private static final String ARG_PARAM2 = &quot;param2&quot;;
  
      // TODO: Rename and change types of parameters
      private String mParam1;
      private String mParam2;
      public int Register=0;
  
  
      public fragment_login() {
          // Required empty public constructor
      }
  
    
      // TODO: Rename and change types and number of parameters
      public static fragment_login newInstance(String param1, String param2) {
          fragment_login fragment = new fragment_login();
          Bundle args = new Bundle();
          args.putString(ARG_PARAM1, param1);
          args.putString(ARG_PARAM2, param2);
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          View v = inflater.inflate(R.layout.fragment_login, container, false);
          send = v.findViewById(R.id.btn_login);
          return v;
  
      }
  
  
      @Override
      public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  
      send.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent intent = new Intent(getActivity(), MainActivity3.class);
                  startActivity(intent);
              // i am calling Mainactivity3 class here ,which takes me to activity layout and it works 
              }
          });
      }
  </code></pre>
  <p>// below is the activity class which get called on clicking button from fragment class and here i am  trying to call back fragment class , but it crash every second time i click this button.</p>
  <pre><code>public class MainActivity3 extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main3);
          Button send = (Button)findViewById(R.id.btn_register);
  
  
          send.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  </code></pre>
  <p>// below code to get back to fragment layout works ony once after fresh loading the app and it crash every second time i click this button.</p>
  <pre><code>      getSupportFragmentManager().beginTransaction().add(R.id.container01,new fragment_login()).commit();
  
  
              }
          });
  </code></pre>