title: What are the advantages of adding a fragment via XML vs programmatically?
body: <p>From the Android <a href="https://developer.android.com/guide/fragments/create" rel="nofollow noreferrer">documentation</a> it's not very clear to me which are the advantages and practical use cases of adding fragments via XML compared to adding them programmatically.</p>
  <p>Do both methods allow sending data from the activity to the fragment and back using Bundle?
  <br>Can both methods behave similarly in the activity lifecycle?</p>
  <p>Some short examples or references will surely help.</p>