webview - Add exception to shouldOverrideUrlLoading in Android Studio? -


i've been trying figure out without luck far... basically, i've got standard webview app call shouldoverrideurlloading. here piece of code

public boolean shouldoverrideurlloading(webview view, string url) {     view.loadurl(url);     return true; } 

but i'd add exception this. exception should be: if url not contain "scheppersonline", not open in webview in standard browser app. tried achieving doing:

public boolean shouldoverrideurlloading(webview view, string url) {     if (url.contains("scheppersonline.be")) {         view.loadurl(url);         return true;     } else {         return false;     } } 

but doesn't seem work. i'm starting out coding, appreciated! :)

logcat:

01-27 13:51:01.406 28229-28229/com.vanbilsen.bram.scheppersmechelen w/cr_bindingmanager: cannot call determinedvisibility() - never saw connection pid: 28229 01-27 13:51:01.422 28229-28229/com.vanbilsen.bram.scheppersmechelen i/chromium: [info:console(1)] "uncaught typeerror: cannot read property 'setattribute' of null", source:  (1) 01-27 13:51:02.238 28229-28229/com.vanbilsen.bram.scheppersmechelen w/cr_bindingmanager: cannot call determinedvisibility() - never saw connection pid: 28229 01-27 13:51:03.894 28229-28229/com.vanbilsen.bram.scheppersmechelen w/cr_bindingmanager: cannot call determinedvisibility() - never saw connection pid: 28229 01-27 13:51:04.064 28229-28229/com.vanbilsen.bram.scheppersmechelen i/chromium: [info:console(129)] "uncaught typeerror: cannot read property 'addeventlistener' of null", source: http://scheppersonline.be/wp-content/themes/accesspress-staple/js/main-menu.js?ver=1.0 (129) 01-27 13:51:08.917 28229-28229/com.vanbilsen.bram.scheppersmechelen d/cr_ime: [imeadapter.java:571] focusednodechanged 01-27 13:51:08.935 28229-28229/com.vanbilsen.bram.scheppersmechelen d/cr_ime: [imeadapter.java:213] updatekeyboardvisibility: type [0], flags [0], show [true] 01-27 13:51:08.936 28229-28229/com.vanbilsen.bram.scheppersmechelen d/cr_ime: [adapterinputconnection.java:178] updatestate [] [0 0] [-1 -1] [true] 01-27 13:51:09.842 28229-28229/com.vanbilsen.bram.scheppersmechelen w/cr_bindingmanager: cannot call determinedvisibility() - never saw connection pid: 28229 01-27 13:51:25.195 28229-28229/com.vanbilsen.bram.scheppersmechelen d/cr_ime: [imeadapter.java:213] updatekeyboardvisibility: type [0], flags [0], show [true] 01-27 13:51:25.195 28229-28229/com.vanbilsen.bram.scheppersmechelen d/cr_ime: [adapterinputconnection.java:178] updatestate [] [0 0] [-1 -1] [true] 01-27 13:51:26.781 28229-28229/com.vanbilsen.bram.scheppersmechelen w/cr_bindingmanager: cannot call determinedvisibility() - never saw connection pid: 28229 

the boolean shouldoverrideurlloading returns true if host application wants leave current webview , handle url itself, otherwise false

to clarify... when return false not saying don't load url. saying ok let webview take care of loading url.

what want like:

public boolean shouldoverrideurlloading(webview view, string url) {      if (!url.contains("scheppersonline.be")) {         intent browserintent = new intent(intent.action_view, uri.parse(url));         startactivity(browserintent);         return true;      } else {          return false;     } } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -