我正在使用WebView和javascript接口,有时候当我在webView上调用loadUrl时,mWebView.getContext()会返回null。
- How can a view have no Context ? Why ?
- Is a view whitout context still used or reusable ?
- What should I do when my view did not have a context ?
- Most important, if the view has no context, will
mWebView.post(new Runnable() { ...
be executed ? Is this code relevant ?
if (Looper.getMainLooper().getThread() == Thread.currentThread()) { mWebView.loadUrl("javascript:..."); } else { mWebView.post(new Runnable() { public void run() { mWebView.loadUrl("javascript:..."); } }); }