我認爲這是不安全的。我在Handler的activity.msgWebView.setVisibility(View.GONE);
處得到NPE。
```Java的
私有靜態類的httpStatusHandler擴展了Handler {
private WeakReference<MessageWebViewActivity> activityWeakReference;
public HttpStatusHandler(WeakReference<MessageWebViewActivity> activityWeakReference) {
this.activityWeakReference = activityWeakReference;
}
@Override
public void handleMessage(Message msg) {
MessageWebViewActivity activity = activityWeakReference.get();
if (activity != null) {
if (msg.what == MSG_URL_OK) {
activity.loadUrl(activity.url);
} else if (msg.what == MSG_URL_ERROR) {
activity.msgWebView.setVisibility(View.GONE);
activity.clPageError.setVisibility(View.VISIBLE);
activity.progressbarLayout.setVisibility(View.GONE);
}
}
}
}
```