Android WebView first page not loading on start after destroy - android

I have a WebView and while it loads the page which takes some seconds I want to show something other than a white screen, so I'm loading static data before loading the first page
webview.loadDataWithBaseURL("/", wait_html, "text/html", "UTF-8", "");
Now, when I press the back button my activity is destroyed and when I restart it, more often than not, I get a warning like:
webcore Can't get the viewWidth after the first layout
and my static content is not displayed but the page that is loaded after is displayed without problems. So... any suggestions on how to make it show my static content?

Related

How can I have a smooth transition between pages on Android WebView

I tried to create an Android WebView App but the transition between pages is weird. It shows a fraction of second of a blank white screen before the next page loads.
I then tried this method to add a sliding animation effect for page loads. But it is worse, as after the "loading" Dialogue box, there is a fraction of a second of the previous page appearing before loading the next page. That creates a jumpy experience for users.
I just wonder how can I make page navigation on WebView to be smooth. I don't need anything fancy. I just want smoothness. The page transition on the mobile browser (e.g. Chrome) is quite smooth in comparison. It also has a blue progress bar indicating that the page is loading. That is perfect for me. I only need a transition that is comparable to the mobile browser experience.
Thank you very much in advance for all your contributions!

Multiple WebViews with a single loading webview with Visibility == GONE makes another webview unresponsive

I am working on an Android browser using WebView(s), and to maintain tabs, multiple webviews are open in a single activity, with 1 always VISIBLE, the rest GONE.
However, when one webview is loading (via .loadUrl()), and then switch to another tab, the 2nd webview with a page already loaded is unresponsive in the sense that I can't click on any links in that until the first webview is loaded.
I can still scroll.
How can I prevent this from happening?
Thanks!

How to stop loading the webview in android

I am worked on tab bar application, The webview is not properly loaded the onReceiveError() method will be called and displayed error description in a alert box. After displaying the alert box the webview is displayed as "WebPage not available" content same as in any browser. How can I display a empty white page after displaying alert box.?. The alert box is displayed in a overlapped way one after the after. How can I display the alert box to specific tab bar.?
You could try webView.clearView() to display an empty white page. Here's the documentation.
Simple :
make your static html error page and put in assets folder , and after receiving error inside onReceiveError() you can load this static html page in web view with your custom message :

disable touch focus while loading

I have an android app that uses a glSurfaceView that takes a few sections to load up.
I have onTouchEvent overridden, and I'm trying to disable focus while it loads but setFocusable(false) isn't working.
The problem is if the user taps on the screen before everything loads, the app gets a null and it crashes.
I'd pop up a progress dialog and use an AsyncTask to do the loading of the view. Once the view is loaded you can kill the dialog. Any heavy lifting should not be done on the UI thread anyway.

Webview building up the memory in Android

In my hybrid Android application, on a ListView item click I'm loading a WebView by passing the WebView activity with the url to display in it. The user can come back to the earlier view by clicking back button.
But what is happening is after clicking on 3-4 ListView items, the app is becoming slow, which I think is because WebView activity is loaded again and again without deallocating it.
In the onDestroy() of the webview activity destroy the WebView as well. myWebView.destroy();

Categories

Resources