webview resetting to index.html when changing orientation

by h...@nnes » Sun, 08 Mar 2009 21:07:50 GMT


Sponsored Links
 Hi all,

I'm trying to get some website as a fullscreen webapp going; using
webview.

So I have a simple CSS layout based on percental width and height to
fill the entire screen on either portrait and landscape.

All is doing fine apart that when I'm navigating away from my
index.html (lets say to index01.html) and doing a orientation change
by opening or closing the keyboard on the G1, the entire page flips
back to index.html.

No idea what's the reason for this and I couldn't find any ressources.
So any help would be highly appreciated.

Thanks a lot, Best, h...@nnes


This is my simple fullscreen code:


 public void onCreate(Bundle icicle) {
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags
(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.main);

        super.onCreate(icicle);
        try{
            WebView wv = new WebView(this);
            wv.getSettings().setJavaScriptEnabled(true);
            wv.getSettings().setJavaScriptCanOpenWindowsAutomatically
(false);
            wv.getSettings().setPluginsEnabled(true);
            wv.getSettings().setSupportMultipleWindows(false);
            wv.getSettings().setSupportZoom(false);
            wv.setVerticalScrollBarEnabled(false);
            wv.setHorizontalScrollBarEnabled(false);
            wv.loadUrl(" http://www.myserver.com/index.html" ;);
            WebViewClient wvc = new WebViewClient();
            wvc.shouldOverrideUrlLoading(wv, " http://www.myserver.com/ 
index.html");
            wv.getSettings().setLoadsImagesAutomatically(true);
            wv.setWebViewClient(wvc);
            setContentView(wv);

--~--~---------~--~----~------------~-------~--~----~



webview resetting to index.html when changing orientation

by Mark Murphy » Sun, 08 Mar 2009 21:12:38 GMT


 


This is expected behavior and has little to do with WebView. By default,
when the screen is rotated, your activity is destroyed and restarted. If
you want to maintain state as the rotation occurs, or otherwise control
how rotation behaves, you will need to add some code.

I have a five-post series on AndroidGuys that covers various
possibilities with respect to handling rotation events:

 http://androidguys.com/?s=rotational +forces

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
Android Training in Sweden --  http://www.sotrium.com/training.php 

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


webview resetting to index.html when changing orientation

by h...@nnes » Mon, 09 Mar 2009 00:54:20 GMT


 Hi Mark, You saved me another time, I remember! Thanks you I really
appreciate that.

I'll check your series. Thanks again, Best, Hannes








--~--~---------~--~----~------------~-------~--~----~



webview resetting to index.html when changing orientation

by h...@nnes » Mon, 09 Mar 2009 00:57:43 GMT


 Those  http://www.androidguys.com/ are quite troublesome to reach from 
Germany. They're down AGAIN or there is some IP country specific
issue. I also rember that from your last post. Best, Hannes





--~--~---------~--~----~------------~-------~--~----~



webview resetting to index.html when changing orientation

by Mark Murphy » Mon, 09 Mar 2009 01:07:27 GMT


 


It may just be routing or traffic issues to Europe. They're definitely
running.

If you search:

rotational forces android

in Google, you can get to the cached copies, or to some sites that
ripped off the posts.

FWIW, that same material is in my Android book.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 

Android Training on the Ranch! -- Mar 16-20, 2009
 http://www.bignerdranch.com/schedule.shtml 

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. moving emails from trash to inbox

is there a way to move emails that have been deleted back to inbox?

2. the correct hprof file location

Is Google aware that docs are listing two hrprof file locations?

hprof dump method gives /sdcard/dump.hprof as the default in docs
whereas monkey dev page indicate data/misc..

ahem  which one is correct?

Assuming that it might be the monkey dev page being wrong..can that be
turned in as a bug report against docs?

Thanks

-- 

3. Delete function not work in notepadv2 android

4. Leading Operators Unite to Unleash Global Apps Potential

5. Android application not playing sound on phone

6. keep button on top of soft keyboard

7. how to find the path of frameworks/base/include/utils/Asset.h ?