I think that the advantage of most interface-based approaches lies in its well-known and readable modularity and a fairly high level of abstraction as a point of view of software development.
Suppose you are working in a team and each team member is responsible for one of these components, for example, it is assumed that you must implement this fragment, and I must implement this activity. Therefore, since we are too far apart, we must agree on a common interface as a standard between us, and then we must implement our components that comply with this standard, in this case, our agreed interface. Also, for software development considerations, a component software system consists of several components that act independently of each other, and their interaction is carried out only by standard common interfaces, and the materials inside each component are transparent to others.
Therefore, in your case, Activity and Fragment should be considered as two separate components, and each of them does not know the details of the other. And here the Java interface appeared.
source share