android - Webview reload page get force close -


im using webview loading webpage , every 5s reload page. page loaded ok after 5s when should start reloading this:

especially @ line 48 method: wvnovamenzacammera.reload();

 01-31 21:01:06.198  26188-26361/com.pfittech.menzauniza e/androidruntime﹕ fatal exception: timer-0     java.lang.runtimeexception: java.lang.throwable: warning: webview method called on thread 'timer-0'. webview methods must called on ui thread. future versions of webview may not support use on other threads.             @ android.webkit.webview.checkthread(webview.java:2093)             @ android.webkit.webview.reload(webview.java:955)             @ com.pfittech.menzauniza.communityfragment$1$1.run(communityfragment.java:48)             @ java.util.timer$timerimpl.run(timer.java:284)      caused by: java.lang.throwable: warning: webview method called on thread 'timer-0'. webview methods must called on ui thread. future versions of webview may not support use on other threads.             @ android.webkit.webview.checkthread(webview.java:2084)             at android.webkit.webview.reload(webview.java:955)             at com.pfittech.menzauniza.communityfragment$1$1.run(communityfragment.java:48)             at java.util.timer$timerimpl.run(timer.java:284) 

there code:

public class communityfragment extends fragment { webview wvnovamenzacammera; private static final string tag = "cammera 1"; private progressdialog progressbarwv1; public communityfragment(){}  @override public view oncreateview(layoutinflater inflater, viewgroup container,         bundle savedinstancestate) {     view rootview = inflater.inflate(r.layout.fragment_community, container, false);     wvnovamenzacammera = (webview)rootview.findviewbyid(r.id.wvcammera1);     getactivity().runonuithread(new runnable() {         public void run() {             websettings websettings = wvnovamenzacammera.getsettings();             wvnovamenzacammera.getsettings().setjavascriptenabled(true);             wvnovamenzacammera.loadurl("http://zuzo.sk/ftp/akt-a.jpg");             new timer().schedule(new timertask() {                 @override                 public void run() {                     // todo auto-generated method stub                     wvnovamenzacammera.reload();                 }             }, 5000, 5000);         }     });     return rootview; } 

change timertask following:

new timertask() {     @override     public void run() {         runonuithread(new runnable() {             public void run() {                 wvnovamenzacammera.reload();             }         });           } } 

as error log says, have reload webview in ui thread, , timertask runs in background thread.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -