简体   繁体   中英

What will happen if send message to handler whose activity has been unvisible?

我在activity onCreate方法中创建了一个处理程序,并启动一个后台线程。在后台线程中,我将调用处理程序的sendMessage方法(在处理程序的handleMessage方法中,我更新了活动的UI),但是活动可能是不可见的,会是什么发生?

If you don't do anything UI-related in that handler, it'll execute fine. Keep in mind that holding references to inactive Activity could create a memory leak - you'll prevent the VM from collecting unused resources.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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