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. move view on touch

In this link http://blahti.wordpress.com/2011/02/10/moving-views-part-3/
you will have a really good tutorial about that.




-- 

2. Logcat debug level --help

Hello All,
I have one dumb question,
when i read a logcat message through command logcat -d, i will get a list of
all events with the prefix I, V, D, W, and E which represent *I*nformation,
*V*erbose, *D*ebug, *W*arning and *E*rror.
I am interested only to display the error messages in the log file( logcat
-f log_error.txt) or to the console( logcat -d).
Can anyone help me to print only the error log messages.

Thanks in advance.

Regards,
Yash Jain.

-- 

3. to retrieve images

4. How to Access SIM Card

5. WTReview : LG Optimus One (LG P500)

6. Upgrading Database from Assets

7. Crash after receiving an admob ad..