Androidはワンツーパンチ 三歩進んで二歩下がる

プログラミングやどうでもいい話

Android4.0でUI(webview)を操作するためにHandler.post()を使うとログに警告が出る

このURLの人と同じような感じでandroid - Unknown Issue with WebView on ICS - Stack Overflow

Warning: A WebView method was called on thread 'WebViewCoreThread'. All WebView methods must be called on the UI thread. Future versions of WebView may not support use on other threads.

という警告メッセージがログに出ました。
このメッセージが出た時は、Handler.post()メソッドを使って

       final Handler handler = new Handler();
       new Thread(new Runnable() {
        
           @Override
           public void run() {
             handler.post(new Runnable() {
        
             @Override
             public void run() {
                mWebView.loadUrl("https://www.google.com/");
             }
          });
         }
        }).start();

のような感じでWebViewを読み込む処理をしていたのですが、それでも警告が出るのですね。
http://stackoverflow.com/questions/9621257/ads-showing-on-honeycomb-webview-but-not-ics-webview
このanswerのようにActivity#runOnUiThread()を使うことで警告が消えました。

        mActivity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mWebView.loadUrl("https://www.google.com/");
            }
        });