According to the documentation of Handler.postDelayed(Runnable r, long delayMillis)
:
Causes Runnable r to be added to the message queue, to run after a specified period of time. Startup in progress. in the thread to which this handler is attached.
On the other hand, View.postDelayed(Runnable action, long delayMillis)
:
Causes Runnable to be added to the message queue that will be started after the specified amount of time has elapsed. The run will be launched on the user interface thread.
I want to know if there is a difference between them when they are called from the main thread and, in particular, if there is a difference when the action is destroyed?
I read an article on how I can flow in an Activity when I use an inner class handler, and I was wondering if View.postDelayed()
could be used to lead to the same problem.
For example, can foo () cause a problem or kill an activity, decide that the anonymous Runnable
class contains an activity reference?
public class MyActiviy extends Activity { private void foo(View v) { v.postDelayed(new Runnable() { public void run() {
source share