简体   繁体   English

定期向处理程序发送消息

[英]Send a message to a handler periodically

In the main activity, I have a handler running on a separate thread.在主要活动中,我有一个在单独线程上运行的处理程序。 I need to send a message to that handler periodically without blocking the ui main thread..How would I do that?我需要定期向该处理程序发送一条消息而不会阻塞 ui 主线程。我该怎么做?

For a generic Java answer, check out timers: http://download.oracle.com/javase/1.4.2/docs/api/java/util/Timer.html For a generic Java answer, check out timers: http://download.oracle.com/javase/1.4.2/docs/api/java/util/Timer.html

For an Android-specific answer, check out AsyncTask: http://developer.android.com/reference/android/os/AsyncTask.html对于 Android 特定的答案,请查看 AsyncTask: http://developer.android.com/reference/android/os/AsyncTask.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM