Your Friends Seem Remote
}
}
}
catch (Throwable t) {
Log.e("PostMonitor", "Exception in poll()", t);
}
}
Step #5: Implement the Client Side..................................................
Next, we need to fix up the Patchy client, so it uses the remote service
interface instead of attempting to access a local PostMonitor.
Then, we need to make one slight modification to our IPostListener
implementation: our anonymous inner class actually has to implement
IPostListener.Stub instead of IPostListener. So, change the listener
implementation to:
private IPostListener listener=new IPostListener.Stub() {
public void newFriendStatus(final String friend,
final String status,
final String createdAt) {
runOnUiThread(new Runnable() {
public void run() {
adapter.insert(new TimelineEntry(friend,
createdAt,
status), 0 );
}
});
}
};
Next, modify your ServiceConnection data member named svcConn to have
following implementation, to change the way we access our service
interface:
private ServiceConnection svcConn=new ServiceConnection() {
public void onServiceConnected(ComponentName className,
IBinder binder) {
service=IPostMonitor.Stub.asInterface(binder);
try {
service.registerAccount(prefs.getString("user", null),
prefs.getString("password", null),
listener);
}