Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
文档和 stackoverflow 都没有对以下问题的答案。
我在我的 Android 应用程序中为 HTTP Get 请求使用 loopj 库。在我的onSuccess()回调中,我正在TextView使用结果更新 a。
onSuccess()
TextView
我很好奇如果回调发生时我Activity不在Activity堆栈前面会发生什么(例如:正在接收呼叫)。我预计它会崩溃。奇怪的是,它并没有崩溃,而且TextView当我回到Activity?
Activity
这怎么可能 ?
它没有崩溃,因为它没有Activity被破坏。但是,不建议在Thread或中更新 UI 组件AsyncTask。
Thread
AsyncTask
如果你真的需要,你可以将结果存储在一个字段中,或者至少,像这样进行检查:
if(myTextView != null) myTextView.setText("results here");