且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

关于runOnUiThread问题

更新时间:2023-02-26 19:33:04

活性的线程code将继续运行,并尝试更新活动的UI。但要注意,在运行到运行时错误的严重危险这样做,你的系统是否停止您的活动因某种原因(如内存溢出。)

The Activity A thread code will still run and try to update the Activity A UI. But be warned, doing this you are at serious risk of running into runtime errors if the system has stopped your activity for any reason(such as running out of memory.)

有更好的做法是在onResume启动线程,并在再次的onPause阻止他们。

It is much better practice to start threads on onResume and stop them again in onPause.