i have webview
in app loads specific web page.
on web page button uses javascript call method within android activity reload url in webview (effectively resetting web app default state).
i've got of javascript interface android bit working few threads here , can pop toast
show app reload, i'm getting error webview.loadurl() call follows.
java.lang.runtimeexception: java.lang.throwable: webview method called on thread 'javabridge'. webview methods must called on same thread. (expected looper looper (main, tid 1) {1d015c84} called on looper (javabridge, tid 122148) {33703881}, fyi main looper looper (main, tid 1) {1d015c84})
i'm guessing because method doing reload not within oncreate
method activity of other webview
stuff i'm not sure if problem , how resolve if - method reloads url needs within javascripinterface class reachable within web-page.
loading page in webview
componenet (or reloading) needs done on ui thread reason, wrapping reload call in runonuithread
resolves issue.
@javascriptinterface public void reloadsite(){ toast.maketext(mcontext, getstring(r.string.reloadingwebapp), toast.length_long).show(); runonuithread(new runnable() { @override public void run() { mwebview = (webview) findviewbyid(r.id.activity_main_webview); mwebview.loadurl(getstring(r.string.web_app_url)); } }); }
Comments
Post a Comment