Android Programming Tutorials

(Romina) #1

TUTORIAL 18


No, Really Listening To Your


Friends


In the previous tutorial, we set up a service to watch for new timeline


entries from our friends. The service merely finds out about these new


statuses – now we need to get those someplace for our activity to display


them.


Step-By-Step Instructions.........................................................................


First, you need to have completed the previous tutorial. If you are


beginning the tutorials here, or if you wish to not use your existing work,


you can download a ZIP file with all of the tutorial results, and you can copy


the 17-CreateService edition of Patchy to use as a starting point.


Step #1: Define the Callback...............................................................


We need to provide some sort of callback to the service, so our activity can


be notified when new status updates are available. With that in mind,


create an Patchy/src/apt/tutorial/IPostListener.java interface as follows:


package apt.tutorial;

public interface IPostListener {
void newFriendStatus(String friend, String status,
String createdAt);
}

183
Free download pdf