“Java SetInterval Equivalent” Kode Jawaban

Java SetInterval Equivalent

new Timer().scheduleAtFixedRate(new TimerTask(){
    @Override
    public void run(){
       Log.i("tag", "A Kiss every 5 seconds");
    }
},0,5000);
// SETINTERVAL
Comfortable Cockroach

Java SetTimeInterval Quivalent

// Param is optional, to run task on UI thread.     
Handler handler = new Handler(Looper.getMainLooper());
Runnable runnable = new Runnable() {
    @Override
    public void run() {
        // Do the task...
        handler.postDelayed(this, milliseconds) // Optional, to repeat the task.
    }
};
handler.postDelayed(runnable, milliseconds);

// Stop a repeating task like this.
handler.removeCallbacks(runnable);
Clumsy Constrictor

Java SetInterval Equivalent


new android.os.Handler(Looper.getMainLooper()).postDelayed(
    new Runnable() {
        public void run() {
            Log.i("tag", "This'll run 300 milliseconds later");
        }
    }, 
300);

Difficult Dragonfly

Jawaban yang mirip dengan “Java SetInterval Equivalent”

Pertanyaan yang mirip dengan “Java SetInterval Equivalent”

Lebih banyak jawaban terkait untuk “Java SetInterval Equivalent” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya