Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old July 30th, 2011, 07:46 AM   #1 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Feb 2011
Location: Ukraine, CK
Posts: 31
 
Device(s): Galaxy Tab 10.1 Galaxy Nexus
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via ICQ to vovs Send a message via Skype™ to vovs
Default how to save content in webView after minimizing app? and do not reloading after restore app?

Have question: in my app I have one webView. When I minimize application and re-open it - in webview I get white space.

I want when I can minimize application and re-open it without reloading content... code here:

Code:
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        url = getPrefProperty(this, CURRENT_URL);
        if(TextUtils.isEmpty(url)){
            //show dialog here
            //getting here url and calling mWebView.loadUrl(url);           
        }
        mWebView = (WebView) findViewById(R.id.webview);
        if (savedInstanceState != null){
            ((WebView)findViewById(R.id.webview)).restoreState(savedInstanceState);
        } else {             
            mWebView.getSettings().setJavaScriptEnabled(true);
            mWebView.getSettings().setPluginsEnabled(true);
            mWebView.getSettings().setSupportZoom(false);
            mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
            mWebView.setWebViewClient(new ManWebViewClient());
            //if(!TextUtils.isEmpty(url)) mWebView.loadUrl(url);
        }
    } 

    protected void onSaveInstanceState(Bundle outState) {
        mWebView.saveState(outState);
     }

    @Override
    protected void onRestoreInstanceState(Bundle state) {
        mWebView.restoreState(state);
        super.onRestoreInstanceState(state);
        //Toast.makeText(getBaseContext(), browser.getUrl(), Toast.LENGTH_LONG).show();
    }

    private class ManWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }

Advertisements
vovs is offline  
Reply With Quote
sponsored links
Reply
Tags
webview


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 02:53 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.