Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Webview - Prevent Reload When Go Back to the App

How to prevent reload on webview when your back to the app? When tapping home key and then back to the app, the webview was reloaded. I dont want this behaviour, I want users to view the previous page (w/o reload) that they accessed.

private WebView webView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    webView = (WebView) findViewById(R.id.webView);
    webView.setWebViewClient(new WebViewClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl( WEBSITE_URL );
}

thanks

like image 535
JR Galia Avatar asked Apr 03 '13 08:04

JR Galia


1 Answers

Test this by adding android:launchMode="singleInstance" to your <activity> element in your androidmanifest.xml.

like image 189
Vaionixx Avatar answered Nov 14 '22 23:11

Vaionixx