Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to fix rotation on webview for Android phones?
    primarykey
    data
    text
    <p>I'm trying to figure out how to fix the orientation problem on webview. Basically every time the user changes the orientation on the device the program goes white and reloads the entire page. This just takes to long.</p> <p>I'd like it to work like every other program that simply adjusts the page size to fit the orientation.I've tried reading other articles on the subject, but when I implement their solution it doesn't seem to fix the problem.</p> <p>Here is my current code.</p> <pre><code>package testdev.HelloWebApp; import android.app.Activity; import android.os.Bundle; import android.view.KeyEvent; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; public class HelloWebAppActivity extends Activity { /** Called when the activity is first created. */ private WebView webView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); webView = (WebView)findViewById(R.id.webView); WebSettings webSettings =webView.getSettings(); webSettings.setJavaScriptEnabled(true); webView.setWebViewClient (new HelloWebViewClient()); webView.loadUrl("http://google.com"); if (savedInstanceState != null) ((WebView)findViewById(R.id.webView)).restoreState(savedInstanceState); } private class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK) &amp;&amp; webView.canGoBack()) { webView.goBack(); return true; } return super.onKeyDown(keyCode, event); } @Override protected void onSaveInstanceState(Bundle outState ){ ((WebView) findViewById(R.id.webView)).saveState(outState); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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