java - #Project - WebView goBack() Return -
after searching on stackoverflow , testing codes, return goback(); doesn't work.
i webview, - url work - zoom work
but need reload last page code added :
mainactivity.java
package org.sbynight.app; import android.app.activity; import android.app.alertdialog; import android.content.dialoginterface; import android.os.bundle; import android.webkit.webview; import android.webkit.webviewclient; import android.webkit.webchromeclient; import android.view.keyevent; public class mainactivity extends activity { webview view; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); webview view = (webview) this.findviewbyid(r.id.webview1); //url du website - not change string url = "http://www.mydomaine.com/"; //loads webview zoomed out view.getsettings().setsupportzoom(true); view.getsettings().setbuiltinzoomcontrols(true); //loads webview client view.getsettings().setloadwithoverviewmode(true); view.setwebviewclient(new webviewclient()); view.setwebchromeclient(new webchromeclient()); view.getsettings().setappcacheenabled(false); //loads url view.loadurl(url); } //loads return url on lastpage @override public boolean onkeydown(int keycode, keyevent event) { if ((keycode == keyevent.keycode_back) && this.view.cangoback()) { this.view.goback(); return true; } else { new alertdialog.builder(this) .seticon(android.r.drawable.ic_dialog_alert) .settitle("fermer sbynight") .setmessage("etes-vous sur de vouloir quittez sbynight?") .setpositivebutton("oui", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { finish(); } }) .setnegativebutton("non", null) .show(); } return true; } }
ps: tested gopressed(); doesn't work too!
so want go last page if there 1 go when key pressed?
use following:
@override public void onbackpressed() { if(this.view.cangoback()) { this.view.goback(); } else { new alertdialog.builder(this) .seticon(android.r.drawable.ic_dialog_alert) .settitle("fermer sbynight") .setmessage("etes-vous sur de vouloir quittez sbynight?") .setpositivebutton("oui", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { finish(); } }) .setnegativebutton("non", null) .show(); } } }
i haven't checked rest of code. invokable function.
Comments
Post a Comment