Slide 8
Slide 8 text
8
࣮ߦྫʢόοΫάϥϯυαʔϏεʣ
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
service = new Intent(this, MyService.class);
startService(service);
public class MyService extends Service {
private Timer timer;
private final TimerTask task = …
@Override
public int onStartCommand(Intent intent, int flags,
int startId) {
timer = new Timer();
timer.scheduleAtFixedRate(task, 0,
TimeUnit.SECONDS.toMillis(10));