title: Loading 2 Web Views on Single Activity in android
body: <p>I have the following code, which will load two different web view upon request.  </p>
  
  <pre><code>public class MultipleWebViewHanlder {  
  public MultipleWebViewHanlder(Context context) {   
          // TODO Auto-generated constructor stub  
          this.context = context;  
              }  
  
  public void MultipleWebViewfun(final String str) {
  
  final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);  
  
              final WebView mWebView = new WebView(context);  
  
              WebSettings settings=mWebView.getSettings(); 
              settings.setJavaScriptEnabled(true);  
              settings.setDatabaseEnabled(true);  
              settings.setDomStorageEnabled(true);  
              settings.setAllowFileAccess(true);  
  
              settings.setBuiltInZoomControls(true);  
              mWebView.setWebChromeClient(new WebChromeClient());  
  
  
  
               JSInterface.handler.post(new Runnable() {  
  
                  @Override  
                  public void run() {  
                      try {  
  
  
                          ((Activity)context).addContentView(mWebView, params);  
                                              mWebView.loadUrl(((Activity)context).getResources().getString(R.string.DemoURL));  
  
                                          } catch (Exception e) {  
                           // TODO Auto-generated catch block  
                           e.printStackTrace();  
                     }
  public class HybridActivity extends Activity {  
       public void onCreate(Bundle savedInstanceState) {  
              super.onCreate(savedInstanceState);  
              WebView webview = new WebView(this);  
              webview.getSettings().setJavaScriptEnabled(true);  
    webview.loadUrl("file:///android_asset/www/html/hyb.html");  
              setContentView(webview);  
  
          MultipleWebViewHanlder webView2 = new MultipleWebViewHanlder (this);
          webView2.MultipleWebViewfun();
  </code></pre>
  
  <p>And I am getting the following exception:  </p>
  
  <p>WebView Core Thread Exception:  </p>
  
  <pre><code>android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. 
  </code></pre>
  
  <p>My log:  </p>
  
  <pre><code>04-24 15:32:08.764: WARN/dalvikvm(13212): threadid=8: thread exiting with uncaught exception (group=0x4001d7d0)  
  04-24 15:32:08.768: ERROR/AndroidRuntime(13212): FATAL EXCEPTION: WebViewCoreThread  
  04-24 15:32:08.768: ERROR/AndroidRuntime(13212): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.  
  04-24 15:32:08.768: ERROR/AndroidRuntime(13212):     at android.view.ViewRoot.checkThread(ViewRoot.java:2826)  
  04-24 15:32:08.768: ERROR/AndroidRuntime(13212):     at android.view.ViewRoot.invalidateChild(ViewRoot.java:616)  
  04-24 15:32:08.768: ERROR/AndroidRuntime(13212):     at android.view.ViewRoot.invalidateChildInParent(ViewRoot.java:642)  
  04-24 15:32:08.768: ERROR/AndroidRuntime(13212):     at android.view.ViewGroup.invalidateChild(ViewGroup.java:2505)  
  04-24 15:32:08.768: ERROR/AndroidRuntime(13212):     at android.view.View.invalidate(View.java:5115)  
  04-24 15:32:08.768: ERROR/AndroidRuntime(13212):     at android.webkit.WebView.viewInvalidate(WebView.java:2616)  
  04-24 15:32:08.768: ERROR/AndroidRuntime(13212):     at android.webkit.WebView.invalidateContentRect(WebView.java:2635)  
  04-24 15:32:08.768: ERROR/AndroidRuntime(13212):     at android.webkit.WebView.access$6400(WebView.java:300)  
  04-24 15:32:08.768: ERROR/AndroidRuntime(13212):     at android.webkit.WebView$PrivateHandler.handleMessage(WebView.java:8072)  
  04-24 15:32:08.768: ERROR/AndroidRuntime(13212):     at android.os.Handler.dispatchMessage(Handler.java:99)  
  04-24 15:32:08.768: ERROR/AndroidRuntime(13212):     at android.os.Looper.loop(Looper.java:123)  
  04-24 15:32:08.768: ERROR/AndroidRuntime(13212):     at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:691)  
  04-24 15:32:08.768: ERROR/AndroidRuntime(13212):     at java.lang.Thread.run(Thread.java:1096)  
  04-24 15:32:08.772: WARN/ActivityManager(2490):   Force finishing activity com.Hy5/.activity.Hy5CanvasActivity  
  </code></pre>