Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to save & restore Webview State?

When I backup & restore the state of my WebView, I receive this message: the webpage at x Address might be temporarily down or may have moved permanently to a new web address.

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);
    webViewShowPoll.saveState(savedInstanceState);                                    
}

@Override
public void onRestoreInstanceState(Bundle outState) {
  super.onRestoreInstanceState(outState);
    webViewShowPoll.restoreState(outState);
}

Androidmanifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SET_DEBUG_APP"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />    
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />    


    <activity
        android:name="com.omid.epoll.mobile.Poll"
        android:launchMode="singleInstance"
        android:label="@string/title_activity_poll" 
        android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
    </activity>
like image 334
Amir Avatar asked Aug 28 '13 04:08

Amir


People also ask

What is the 30 day rule?

With the 30 day savings rule, you defer all non-essential purchases and impulse buys for 30 days. Instead of spending your money on something you might not need, you're going to take 30 days to think about it. At the end of this 30 day period, if you still want to make that purchase, feel free to go for it.

What's the 50 30 20 budget rule?

What is the 50/30/20 rule? The 50/30/20 rule is an easy budgeting method that can help you to manage your money effectively, simply and sustainably. The basic rule of thumb is to divide your monthly after-tax income into three spending categories: 50% for needs, 30% for wants and 20% for savings or paying off debt.


1 Answers

 if (isInternetPresent) {
        // Internet Connection is Present
        // make HTTP requests
        // showAlertDialog(HomeScreen.this, "Internet Connection",
        // "You have internet connection", true);

        webviewbrowse.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
        webviewAds.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
        webviewbrowse.loadUrl("http://www.example.com");
    } else {
        // Internet connection is not present
        // Ask user to connect to Internet
        webviewbrowse.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        webviewAds.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        webviewbrowse.loadUrl("http://example.com");
        showAlertDialog(HomeScreen.this, "internet doesn't connect",
                " please connect to internet", false);
    }
like image 73
Mohammed Saleem Avatar answered Sep 21 '22 20:09

Mohammed Saleem