java - WebView falsely shows my "no connection"-page -
i've made webview checks net connection , if there none display error-page.
it worked fine until when display error-page though me having cellular info on, persists on wifi's.
package se.welovecode.tismatapp; import android.support.v7.app.actionbaractivity; import android.annotation.suppresslint; import android.os.bundle; import android.view.keyevent; import android.view.window; import android.webkit.websettings; import android.webkit.webview; import android.webkit.webviewclient; @suppresslint("setjavascriptenabled") public class mainactivity extends actionbaractivity { webview mywebview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); setcontentview(r.layout.activity_main); final webview mywebview = (webview) findviewbyid(r.id.webview); mywebview.loadurl("http://www.welovecode.se/t-matapp"); websettings websettings = mywebview.getsettings(); websettings.setjavascriptenabled(true); mywebview.setwebviewclient(new webviewclient() { public void onreceivederror(webview view, int errorcode, string description, string failingurl) { mywebview.loadurl("file:///android_asset/index.html"); } }); } @override public boolean onkeydown(int keycode, keyevent event) { if (keycode == keyevent.keycode_back) { homecoming false; } homecoming super.onkeydown(keycode, event); } };
use view.loadurl("file:///android_asset/index.html");
instead of using mywebview();
java android webview android-webview
No comments:
Post a Comment