Skip to content

Instantly share code, notes, and snippets.

@johnty
Created November 13, 2014 17:20
Show Gist options
  • Save johnty/b7bb118283793836da22 to your computer and use it in GitHub Desktop.
Save johnty/b7bb118283793836da22 to your computer and use it in GitHub Desktop.
android snippet for triggering periodic events
private Handler handler = new Handler();
//trigger next event.
handler.postDelayed(runnable, SAMPLE_INTERVAL_MS);
private Runnable runnable = new Runnable() {
//this class deals with generating periodic events,
// to emulate the incoming "midi messages" from device
// at a given rate
@Override
public void run() {
if (REPEAT) { //mechanism for turning on/off
//arm for next event
handler.postDelayed(runnable, SAMPLE_INTERVAL_MS);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment