lwc:programming:mobile:android:threads

This is an old revision of the document!


A hodge-podge of tips, snippets, etc. in my journey to figure out the Android thread thing.

With Handler

I assume since this is with Handler and Runnable that this is in a separate thread? How to confirm?

final Handler handler = new Handler();
final int delay = 1000; // 1000 milliseconds == 1 second

handler.postDelayed(new Runnable() {
    public void run() {
        System.out.println("myHandler: here!"); // Do your work here
        handler.postDelayed(this, delay);
    }
}, delay);

With Timer

Does this run in separate thread?

new Timer().scheduleAtFixedRate(new TimerTask() {
    @Override
    public void run() {
        //your method
    }
}, 0, 1000);//put here time 1000 milliseconds=1 second
  • lwc/programming/mobile/android/threads.1642458078.txt.gz
  • Last modified: 2022/01/17 16:21
  • by John Harrison