Skip to content

Instantly share code, notes, and snippets.

@anitaa1990
Created May 16, 2018 16:46
Show Gist options
  • Save anitaa1990/ccd5939857686a996db60b8060b08ad5 to your computer and use it in GitHub Desktop.
Save anitaa1990/ccd5939857686a996db60b8060b08ad5 to your computer and use it in GitHub Desktop.
public class HandlersReferenceLeakActivity extends AppCompatActivity {
private TextView textView;
/*
* Mistake Number 1
* */
private Handler leakyHandler = new Handler();
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
/*
* Mistake Number 2
* */
leakyHandler.postDelayed(new Runnable() {
@Override
public void run() {
textView.setText(getString(R.string.text_handler_1));
}
}, 5000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment