I have a Main Activity with a bunch of Fragments connected to it.

One of the fragments has to be able to recieve data from MainActivity *after* it has been loaded in the FragmentTransaction and committed.

What is the best way to call a method in that specific fragment?

Do I have to implement a Interface and include it in the MainActivty just for this one fragment? Is there a better way? Can someone point me in the correct direction?

What I have tried now : (Failing at settings ContactsInterface in the MainActivity)

**ContactsInterface**

```
public interface ContactsInterface {

   void notifyDenied();
   void notifyGranted();

```

}

**Fragment**

```
Class.... implements ContactsInterface...

@Override
public void notifyDenied() {
    Log.d("DENIED", "DENIED CALLBACK");
}
@Override
public void notifyGranted() {
    Log.d("GRANTED", "GRANTED CALLBACK");
}

```

**Main Activity**

```
try {
     contactsInterface = (ContactsInterface) this.getApplicationContext();
} catch (ClassCastException e) {
     throw new ClassCastException(this.toString()
                + " Needs to implement the methods");
}

```

Last example throws an ClassCastException.