java - How to send data from an activity to a Fragment in Android using interfaces? -


the android fragments tutourial teaches how send data fragment activity in using interfaces. don't understand interfaces , nobody gives example of how use them not docs.oracle.com. want know how recreate locationlistener, i:

1) implement interface in class a

2) set handler example :setinterfacehandler(this) in class a

3) add implementation of interface in class foe example:

public void onsomethinghappened(string s) {   // } 

4) periodically have class b fire off events caught handler class in a

for example: android periodically give activity location updates (dont know how this).

of course can use java language mechanisms , design patterns purpose (interfaces, handlers, ...) ... or might have @ dedicated android framework solutions problem like:

with these approaches able fire events class b , handle them in class clean , "android like" design.


Comments