A Andras Active Member Licensed User Longtime User Mar 9, 2012 #1 Is there a simple way of clearing a webview window while a new page is loading - and perhaps displaying a progress bar or similar in the meantime? And perhaps putting up a suitable message if the site fails to load...? Thanks! John
Is there a simple way of clearing a webview window while a new page is loading - and perhaps displaying a progress bar or similar in the meantime? And perhaps putting up a suitable message if the site fails to load...? Thanks! John
lagore Active Member Licensed User Longtime User Mar 9, 2012 #2 Hi You could use Code: Copy WebView1.LoadHtml("<html><body>Loading Page</body></html>") and create a clear panel with an indeterminate progress bar overlayed on top of the webview then remove it when the 'PageFinished' event has fired. Upvote 0
Hi You could use Code: Copy WebView1.LoadHtml("<html><body>Loading Page</body></html>") and create a clear panel with an indeterminate progress bar overlayed on top of the webview then remove it when the 'PageFinished' event has fired.
A Andras Active Member Licensed User Longtime User Mar 9, 2012 #3 Interesting and I'd been thinking along similar lines, but it doesn't seem to work; the original page stays visible until the new one loads. And a question about the PageFinished event - it requires a string parameter, but what? Not the URL as I had assumed, as this throws up a Java error. Sorry for the confusion! John Upvote 0
Interesting and I'd been thinking along similar lines, but it doesn't seem to work; the original page stays visible until the new one loads. And a question about the PageFinished event - it requires a string parameter, but what? Not the URL as I had assumed, as this throws up a Java error. Sorry for the confusion! John
NJDude Expert Licensed User Longtime User Mar 9, 2012 #4 It is not necessary to enter the string parameter in PageFinish if it's not needed. Upvote 0
lagore Active Member Licensed User Longtime User Mar 9, 2012 #5 The string parameter is the Url of the page just loaded it is handed to the sub "PageFinished" by the system not something you set. The only way to get the 'clear Screen' to show with message between is to not load the second web until the 'clear screen' has finished loading. Code: Copy Sub WebView1_PageFinished (Url As String) If Url = "file:///" Then WebView1.LoadUrl("http://maps.google.com/") End If End Sub The returned Url of Code: Copy WebView1.LoadHtml("<html><body>Loading Page</body></html>") is "file:///" so it wipes the first webview then displays "Loading Page" and then loads the next page. This can happen fairly quickly depending on connection and page size. Upvote 0
The string parameter is the Url of the page just loaded it is handed to the sub "PageFinished" by the system not something you set. The only way to get the 'clear Screen' to show with message between is to not load the second web until the 'clear screen' has finished loading. Code: Copy Sub WebView1_PageFinished (Url As String) If Url = "file:///" Then WebView1.LoadUrl("http://maps.google.com/") End If End Sub The returned Url of Code: Copy WebView1.LoadHtml("<html><body>Loading Page</body></html>") is "file:///" so it wipes the first webview then displays "Loading Page" and then loads the next page. This can happen fairly quickly depending on connection and page size.
A Andras Active Member Licensed User Longtime User Mar 9, 2012 #6 Yes, thanks, I've just spent half an hour playing with it and came to that conclusion! It's actually probably easier to just display the new panel on top of the webview until the PageFinished event has done its job; this seems seems quite happy to work with WebView1_PageFinished ("dummy"). The indeterminate bar is fine as far as it goes, but I'd been expecting the 'barbers pole' animation rather than this; or is that a 'feature' of some devices? If not, is it available here - doesn't seem to show up in any of the libraries? Thanks again, John Upvote 0
Yes, thanks, I've just spent half an hour playing with it and came to that conclusion! It's actually probably easier to just display the new panel on top of the webview until the PageFinished event has done its job; this seems seems quite happy to work with WebView1_PageFinished ("dummy"). The indeterminate bar is fine as far as it goes, but I'd been expecting the 'barbers pole' animation rather than this; or is that a 'feature' of some devices? If not, is it available here - doesn't seem to show up in any of the libraries? Thanks again, John
lagore Active Member Licensed User Longtime User Mar 9, 2012 #7 As standard there only 2 versions of progress in B4A, the spinning wheel (indeterminate) and horizontal which it is up to you to increment. Android does have a horizontal indeterminate version ' Widget.ProgressBar.Horizontal' you should be able to use the Reflector library to implement this (if only I knew how?) Upvote 0
As standard there only 2 versions of progress in B4A, the spinning wheel (indeterminate) and horizontal which it is up to you to increment. Android does have a horizontal indeterminate version ' Widget.ProgressBar.Horizontal' you should be able to use the Reflector library to implement this (if only I knew how?)
thedesolatesoul Expert Licensed User Longtime User Mar 9, 2012 #8 lagore said: As standard there only 2 versions of progress in B4A, the spinning wheel (indeterminate) and horizontal which it is up to you to increment. Android does have a horizontal indeterminate version ' Widget.ProgressBar.Horizontal' you should be able to use the Reflector library to implement this (if only I knew how?) Click to expand... Try this untested code: Code: Copy Sub setIndeterminate(pb as ProgressBar) Dim r As Reflector r.Target = pb r.RunMethod2("setIndeterminate",true, "java.lang.boolean") End Sub Upvote 0
lagore said: As standard there only 2 versions of progress in B4A, the spinning wheel (indeterminate) and horizontal which it is up to you to increment. Android does have a horizontal indeterminate version ' Widget.ProgressBar.Horizontal' you should be able to use the Reflector library to implement this (if only I knew how?) Click to expand... Try this untested code: Code: Copy Sub setIndeterminate(pb as ProgressBar) Dim r As Reflector r.Target = pb r.RunMethod2("setIndeterminate",true, "java.lang.boolean") End Sub
margret Well-Known Member Licensed User Longtime User Mar 9, 2012 #9 I use this in one of my apps to clear the WebView and it works fine on the target device. Android 2.3. Code: Copy Sub ClearWV WebView1.LoadUrl("") WebView1.Invalidate DoEvents End Sub Upvote 0
I use this in one of my apps to clear the WebView and it works fine on the target device. Android 2.3. Code: Copy Sub ClearWV WebView1.LoadUrl("") WebView1.Invalidate DoEvents End Sub
A Andras Active Member Licensed User Longtime User Mar 10, 2012 #10 thedesolatesoul said: Try this untested code: Code: Copy Sub setIndeterminate(pb as ProgressBar) Dim r As Reflector r.Target = pb r.RunMethod2("setIndeterminate",true, "java.lang.boolean") End Sub Click to expand... Interesting, but promptly throws up a 'Missing Library?' error for Reflector. John Upvote 0
thedesolatesoul said: Try this untested code: Code: Copy Sub setIndeterminate(pb as ProgressBar) Dim r As Reflector r.Target = pb r.RunMethod2("setIndeterminate",true, "java.lang.boolean") End Sub Click to expand... Interesting, but promptly throws up a 'Missing Library?' error for Reflector. John
thedesolatesoul Expert Licensed User Longtime User Mar 10, 2012 #11 Scrap that. You can just do: Pb.indeterminate = true But you will get the spinning animation not the barbers pole. I don't think barbers pole is possible without rewrapping the Progressbar. Sent from my GT-I9000 using Tapatalk Upvote 0
Scrap that. You can just do: Pb.indeterminate = true But you will get the spinning animation not the barbers pole. I don't think barbers pole is possible without rewrapping the Progressbar. Sent from my GT-I9000 using Tapatalk
A Andras Active Member Licensed User Longtime User Mar 11, 2012 #12 Just a note to say Thanks to all for the very helpful answer! John Upvote 0
M mcmanu Active Member Licensed User Longtime User Apr 30, 2012 #13 hi I have the same Problem I load images into a webview. Now when i used this function and close my app and open it again it crashes its because of the webview I tried Sub ClearWV WebViewtown1.LoadUrl("") WebViewtown1.Invalidate DoEvents End Sub but it didn´t help I have a galaxy s2 with android 4.0.3 Hope you can help me out Upvote 0
hi I have the same Problem I load images into a webview. Now when i used this function and close my app and open it again it crashes its because of the webview I tried Sub ClearWV WebViewtown1.LoadUrl("") WebViewtown1.Invalidate DoEvents End Sub but it didn´t help I have a galaxy s2 with android 4.0.3 Hope you can help me out
Erel B4X founder Staff member Licensed User Longtime User May 1, 2012 #14 You should check the logs and post the error message. Upvote 0
M mcmanu Active Member Licensed User Longtime User Jul 1, 2012 #15 Hi Erel Sorry for dont answering this i think its this line in the logs --> Fatal signal 11 (SIGSEGV) at 0x546406e4 (code=2) Every time i use a funktion with webview(loading a bitmap) and i close my app, this error is in the log If i use recycle to recycle the webview it logs this --> java.lang.NoSuchMethodException: recycle [boolean] at java.lang.Class.getConstructorOrMethod(Class.java:460) at java.lang.Class.getDeclaredMethod(Class.java:685) at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(Reflection.java:192) at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod2(Reflection.java:795) at webview.android.main._activity_pause(main.java:233) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:136) at webview.android.main.onPause(main.java:159) at android.app.Activity.performPause(Activity.java:4563) at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1198) at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2705) at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2674) at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2652) at android.app.ActivityThread.access$800(ActivityThread.java:127) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1170) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4507) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) at dalvik.system.NativeStart.main(Native Method) java.lang.NoSuchMethodException: recycle [boolean] Last edited: Jul 1, 2012 Upvote 0
Hi Erel Sorry for dont answering this i think its this line in the logs --> Fatal signal 11 (SIGSEGV) at 0x546406e4 (code=2) Every time i use a funktion with webview(loading a bitmap) and i close my app, this error is in the log If i use recycle to recycle the webview it logs this --> java.lang.NoSuchMethodException: recycle [boolean] at java.lang.Class.getConstructorOrMethod(Class.java:460) at java.lang.Class.getDeclaredMethod(Class.java:685) at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(Reflection.java:192) at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod2(Reflection.java:795) at webview.android.main._activity_pause(main.java:233) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:136) at webview.android.main.onPause(main.java:159) at android.app.Activity.performPause(Activity.java:4563) at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1198) at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2705) at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2674) at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2652) at android.app.ActivityThread.access$800(ActivityThread.java:127) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1170) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4507) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) at dalvik.system.NativeStart.main(Native Method) java.lang.NoSuchMethodException: recycle [boolean]
Erel B4X founder Staff member Licensed User Longtime User Jul 2, 2012 #16 You are doing something wrong with the Reflection library. Upvote 0
M mcmanu Active Member Licensed User Longtime User Jul 2, 2012 #17 Hi erel This is my code --> Code: Copy dim o4 As Reflector o4.Target = webview1 o4.RunMethod2("recycle","True","java.lang.boolean" ) When i use Exitapplication (userclosed=true) after loading a bitmap into a webview (picture comes from a website via loadurl) then the log gives this error --> Fatal signal 11 (SIGSEGV) at 0x53a576e4 (code=1) what does this mean? if i use webview to load bitmaps into it and in activity_pause exitapplication it chrashes everytime on second start. I have a galaxy s2 with android 4.0.3 (i think the problem is only in ics) Sample Projekt webviewissue --> http://www.b4x.com/forum/german-forum/19150-ram-problem.html Hope you can help me , because this error is very annoying Last edited: Jul 2, 2012 Upvote 0
Hi erel This is my code --> Code: Copy dim o4 As Reflector o4.Target = webview1 o4.RunMethod2("recycle","True","java.lang.boolean" ) When i use Exitapplication (userclosed=true) after loading a bitmap into a webview (picture comes from a website via loadurl) then the log gives this error --> Fatal signal 11 (SIGSEGV) at 0x53a576e4 (code=1) what does this mean? if i use webview to load bitmaps into it and in activity_pause exitapplication it chrashes everytime on second start. I have a galaxy s2 with android 4.0.3 (i think the problem is only in ics) Sample Projekt webviewissue --> http://www.b4x.com/forum/german-forum/19150-ram-problem.html Hope you can help me , because this error is very annoying
Erel B4X founder Staff member Licensed User Longtime User Jul 3, 2012 #18 Where did you see a reference to this recycle method? Why are you calling ExitApplication? It should normally not be used. Upvote 0
Where did you see a reference to this recycle method? Why are you calling ExitApplication? It should normally not be used.
M mcmanu Active Member Licensed User Longtime User Jul 3, 2012 #19 Erel said: Where did you see a reference to this recycle method? Why are you calling ExitApplication? It should normally not be used. Click to expand... What do you mean by where did you see a reference? I downloaded the reflection library and set this code into activity_pause I need exit application because, if i dont use exitapplication the ram is increasing everytime i start my app again. With Exitapplication the ram is not increasing. How can i handle this problem that my ram is getting fuller and fuller with every new start of my application? I use a lot of bitmaps (with loadbitmapsample) some bitmaps are loading in webviews. Is this my recycle code wrong? Last edited: Jul 3, 2012 Upvote 0
Erel said: Where did you see a reference to this recycle method? Why are you calling ExitApplication? It should normally not be used. Click to expand... What do you mean by where did you see a reference? I downloaded the reflection library and set this code into activity_pause I need exit application because, if i dont use exitapplication the ram is increasing everytime i start my app again. With Exitapplication the ram is not increasing. How can i handle this problem that my ram is getting fuller and fuller with every new start of my application? I use a lot of bitmaps (with loadbitmapsample) some bitmaps are loading in webviews. Is this my recycle code wrong?
warwound Expert Licensed User Longtime User Jul 3, 2012 #20 It could be that the WebView is using a lot of memory to hold items in it's cache. Try using my WebViewExtras library to clear the cache: Code: Copy MyWebViewExtras.clearCache(MyWebView, ??) Experiment with values of True and False for ?? includeDiskFiles: IncludeDiskFiles - If false, only the RAM cache is cleared. Click to expand... There's no point clearing disk files unless you really want to - clearing disk files will negate the speed gain of having cached files. Martin. Upvote 0
It could be that the WebView is using a lot of memory to hold items in it's cache. Try using my WebViewExtras library to clear the cache: Code: Copy MyWebViewExtras.clearCache(MyWebView, ??) Experiment with values of True and False for ?? includeDiskFiles: IncludeDiskFiles - If false, only the RAM cache is cleared. Click to expand... There's no point clearing disk files unless you really want to - clearing disk files will negate the speed gain of having cached files. Martin.