Implement interface of fragment in multiple activities
<p>Ok so i have an activity A that has a fragment A, and an Activity B that has a fragment B. Activity A is the main screen(like a login screen). Now in fragment B, i try to do some work and when there is a session expired, i send a message, logout and go back to the main screen A. </p>

<p>Now fragment B has an interface which it uses to communicate with the Activity B for other different functions. Should My Activity A implement this same interface of fragment B just for this logout session or is there a better way?</p>

<p>An illustration:</p>

<pre><code>public class fragmentB extends Fragment {


    public interface FragmentBProgressListener {
        public void onShowDataDialog();
        public void onRemoveData();
        public void onSessionError(String errordata);
    }


   //or should i have another interface that implements this only in activity A 

}
</code></pre>

<p>Activity B:</p>

<pre><code>public class ActivityB extends Activity implements FragmentBProgressListener {


    public void onShowDataDialog(){

      }


     public void onRemoveData(){

    }


    public void onSessionError(String errordata){
          // finish Activity here
   }


}
</code></pre>

<p>Activity A:</p>

<pre><code>public class ActivityA extends Activity implements FragmentAListener, FragmentBFragmentBProgressListener {


     public void onFragA(){

   }


     public void onShowDataDialog(){

      }


     public void onRemoveData(){

    }


    public void onSessionError(String errordata){
          // show error dialog here from fragment B
   }
}
</code></pre>

<p>is this a good way? any pitfalls i should be aware of?</p>
