Created
December 22, 2016 13:00
-
-
Save agustarc/3c39e6407e57d0a1ac109b1189ae80ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NonLeakActivity extends Activity { | |
private NonLeakHandler handler = new NonLeakHandler(this); | |
private static final class NonLeakHandler extends Handler { | |
private final WeakReference<NonLeakActivity> ref; | |
public NonLeakHandler(NonLeakActivity act) { | |
ref = new WeakReference<>(act); | |
} | |
@Override | |
public void handleMessage(Message msg) { | |
NonLeakActivity act = ref.get(); | |
if (act != null) { | |
// do work | |
} | |
} | |
} | |
private static final Runnable runnable = new Runnable() { | |
@Override | |
public void run() {} | |
} | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
handler.postDelayed(runnable, 60000); | |
finish(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment