Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to go back to previous page if back button is pressed in WebView?
    primarykey
    data
    text
    <p>I have an app in which I have a <code>WebView</code> where I display some websites. It works, clicking a link in the webpage goes to the next page in the website inside my app. But when I click the phone's back button, it takes me straight into my app. I want to go back to the previous page in the website instead. How can I do this?</p> <p>Here is the code sample I'm using:</p> <pre><code>public class Webdisplay extends Activity { @Override public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); this.getWindow().requestFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.webdisplay); getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON); Toast loadingmess = Toast.makeText(this, "Cargando El Diario de Hoy", Toast.LENGTH_SHORT); loadingmess.show(); WebView myWebView; myWebView = (WebView) findViewById(R.id.webview); myWebView.getSettings().setJavaScriptEnabled(true); myWebView.loadUrl("http://www.elsalvador.com"); myWebView.setWebViewClient(new WebViewClient()); myWebView.setInitialScale(1); myWebView.getSettings().setBuiltInZoomControls(true); myWebView.getSettings().setUseWideViewPort(true); final Activity MyActivity = this; myWebView.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { MyActivity.setTitle("Loading..."); MyActivity.setProgress(progress * 100); if(progress == 100) MyActivity.setTitle(R.string.app_name); } }); } } </code></pre>
    singulars
    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