3

I am making a basic WebView app that will load a web page. This web page requires log in information. When I navigate out or refresh the page it logs me out. How do I stay logged in? The following code is my attempt based on some research but apparently I am not understanding the concept. And so I can kill two bird with one stone, can someone let me know how to prevent a refresh of the page when you rotate your phone? is this possible? Thanks for any help in advanced.

    public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  mWebView = (WebView) findViewById(R.id.webview);
  mWebView.getSettings().setJavaScriptEnabled(true);
  mWebView.loadUrl("www.randomurl.com");
  mWebView.setWebViewClient(new HelloWebViewClient());
  CookieSyncManager.createInstance(this);
  CookieSyncManager.getInstance().startSync();
  CookieManager.getInstance();
 }
Kevin Moore
  • 243
  • 1
  • 6
  • 15

1 Answers1

5

The two problems i posted were actually related. Apparently whenever a orientation change or when i navigated out of the web page, the data would be destroyed so i added this method

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
}

Hopefully this will be useful for other people!

Kevin Moore
  • 243
  • 1
  • 6
  • 15