Skip to content

Instantly share code, notes, and snippets.

@gimite
Created August 8, 2009 01:07
Show Gist options
  • Save gimite/164255 to your computer and use it in GitHub Desktop.
Save gimite/164255 to your computer and use it in GitHub Desktop.
import java.util.Timer;
import java.util.TimerTask;
import android.app.Service;
import android.os.Handler;
public class MyService extends Service {
private Handler handler = new Handler();
private Timer timer;
public void onCreate() {
super.onCreate();
timer = new Timer();
timer.schedule(new UpdateTask(), 0, 300);
}
private class UpdateTask extends TimerTask {
public void run() {
handler.post(new Runnable() {
public void run() {
// 実際の処理...
}
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment