title: How onAttach() gets to know which activity is calling it (Android Studio)
body: <pre><code> @Override
  public void onAttach(Activity activity) {
      super.onAttach(activity);
      try{
          activityCommander = (TopSectionListener) activity;
      }catch (ClassCastException e){
          throw new ClassCastException(activity.toString());
      }
  }
  </code></pre>
  
  <p>I  Want to know how an Activity calls onAttach of fragment , so that fragment comes to know by which activity it is called or attached to ?</p>