android:如何验证仍在内存中的视图对象?

android:如何验证仍在内存中的视图对象?,android,Android,我正在使用自定义线程将图像从URL提取到ImageView中,我执行了以下操作: public class FetchThumbThread implements Runnable { ImageView gImage; String gUri; public FetchThumbThread(Object imageView, String uri) { // store parameter for later user gImage =

我正在使用自定义线程将图像从URL提取到ImageView中,我执行了以下操作:

public class FetchThumbThread implements Runnable {
    ImageView gImage;
    String gUri;
    public FetchThumbThread(Object imageView, String uri) {
        // store parameter for later user
        gImage = (ImageView)imageView;
        gUri = uri;
    }

    public void run() {
        // fetch the image and store it in buffer.
        new runnable to be running in UIThread () {
            if (gImage still in memory) {
                 updating gImage;
            }
        }
    }
}
将imageview作为参数传递,并在run()中更新它(将在UIThread()中更新)

但是如果ImageView已经被破坏(用户按下刷新按钮),我需要验证gImage指针是否已经消失。。。否则程序将崩溃


如何在android中实现这一点?

通常,当您的活动不再有效时,您会在runnable中将其清空。然后,当您在UI线程上执行更新gImage的工作时,只需检查以确保imageView不为null