I've got a view in a RecyclerView. And I call myView.post(runnable) in onBindViewHolder() method to gather information about myView after the layout pass finishes. Is there any risk of crashing my application if the host activity gets destroyed somehow before my runnable starts?
Asked
Active
Viewed 480 times
1 Answers
0
In general its safe. However if your onDestroy releases any resources or nulls out any variables that your Runnable depends on you could hit a corner case. For the most part I wouldn't worry about it though. It can't be called after finalize(), because the Runnable will keep a reference to your activity preventing it from being garbage collected until after the Runnable is run. That would be the real problem, but the framework/language prevent it.

Gabe Sechan
- 90,003
- 9
- 87
- 127