Created
May 16, 2018 16:46
-
-
Save anitaa1990/ccd5939857686a996db60b8060b08ad5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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