Skip to content

Instantly share code, notes, and snippets.

@Jhonnyc
Jhonnyc / ActivityMain.java
Last active August 31, 2017 22:06
A simple gist to describe how to create an activity with a Timer - once the time is up (counting down) we can call an action. This is especially usefull for communicating with a time-based session server (streaming, highly secured server etc..).
public class ActivityMain extends AppCompatActivity {
private final int SESSION_LENGTH = 5000; // Session length in milliseconds
// Class vars
private View mSessionedView;
private Handler mHandler;
private Runnable mAction = new Runnable() {
@Override
public void run() {