Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid WebView not loading on Nexus 4 and Nexus 7
    text
    copied!<p>I have an activity in my app that displays a WebView. The WebView never loads on my Nexus 4 or Nexus 7 devices (both running Jellybean 4.2). Every other device I've tested on works fine.</p> <p>Here's the activity code and the layout:</p> <pre><code>public class SuperWebView extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { setContentView(R.layout.web_view); final String URL = getIntent().getExtras().getString("URL"); loadWebView(URL); } catch (Exception e) { Log.e(getLocalClassName(), "== onCreate == " + e.toString()); e.printStackTrace(); } } private void loadWebView(String URL) { WebView mWebView = (WebView) findViewById(R.id.wvContainer); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { Log.d("WebView", "onPageFinished"); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Log.d("WebView", "shouldOverrideUrlLoading"); view.loadUrl(url); return true; } @Override public void onPageStarted(WebView view, String url, android.graphics.Bitmap favicon) { Log.d("WebView", "onPageStarted"); } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Log.d("WebView", "onRecievedError"); } }); Log.d(getLocalClassName(), "Loading URL: " + URL); mWebView.loadUrl("http://www.google.com"); } } </code></pre> <p>And here's the layout it uses (res/layout/web_view.xml):</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/header" android:paddingLeft="5dp" android:paddingRight="5dp" &gt; &lt;TextView android:id="@+id/tvHeaderText" style="@style/MastHeadTitle" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="@string/ship_method" &gt; &lt;/TextView&gt; &lt;Button android:id="@+id/btnWebViewBack" style="@style/MastHeadButton" android:layout_alignParentLeft="true" android:text="@string/back_button_text" &gt; &lt;/Button&gt; &lt;TextView android:id="@+id/tvWebViewRight" style="@style/cartMofNText" android:text="@string/step_2_4" &gt; &lt;/TextView&gt; &lt;/RelativeLayout&gt; &lt;WebView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/wvContainer" android:layout_width="match_parent" android:layout_height="match_parent" /&gt; </code></pre> <p></p> <p>I've been trying to figure out this issue for days now and cannot find any information on it anywhere. None of the WebViewClient methods I override ever get fired, and the WebView remains blank/invisible. I tried using clearCache, clearView, reloadView, etc. and nothing worked. </p> <p>I also have another activity that uses a WebView elsewhere in the app, and it works fine UNTIL I try to run this SuperWebView activity, then they both break. I also tried loading a local HTML file from the assets folder and it didn't work either.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload