I need my app to trigger an alert a specified amount of time after a user presses a button. The documentation makes it look like Handler is what I need, and usage appears to be brain dead.
However, I'm finding that despite using postDelayed, my routine is running immediately. I know I'm missing something obvious, but I just can't see it. Why does the code below make the phone vibrate the immediately rather than waiting a minute?
...
final Button button = (Button) findViewById(R.id.btnRun);
final Handler handler = new Handler();
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
...
handler.postDelayed(Vibrate(), 60000);
}
});
...
private Runnable Vibrate() {
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(300);
return null;
}