Android Programming Tutorials

(Romina) #1
No, Really Listening To Your Friends

TextView getStatus() {
if (status==null) {
status=(TextView)row.findViewById(R.id.status);
}

return(status);
}
}
}

Similarly, here is a full implementation of PostMonitor as of this point:


package apt.tutorial.two;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.os.SystemClock;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import winterwell.jtwitter.Twitter;
import apt.tutorial.IPostListener;
import apt.tutorial.IPostMonitor;

public class PostMonitor extends Service {
private static final int POLL_PERIOD= 60000 ;
private AtomicBoolean active=new AtomicBoolean(true);
private Set<Long> seenStatus=new HashSet<Long>();
private Map<IPostListener, Account> accounts=
new ConcurrentHashMap<IPostListener, Account>();
private final Binder binder=new LocalBinder();

@Override
public void onCreate() {
super.onCreate();

new Thread(threadBody).start();
}

@Override
public IBinder onBind(Intent intent) {
return(binder);
}

@Override
public void onDestroy() {
super.onDestroy();

198
Free download pdf