android - web view url goes to browser .how to do avoid and open in same web view? -



android - web view url goes to browser .how to do avoid and open in same web view? -

here code...am implemented webviewclient concept.it works in web view..in app have content saring via fb,twitter,g+,,,fb login , open in webview...but when click share fb icon in app after process work on browser..but want process in webview only...

oncreate

webview = (webview) findviewbyid(r.id.webview1); webview.setclickable(true); webview.setfocusableintouchmode(true); webview.getsettings().setjavascriptenabled(true); webview.setwebviewclient(new mywebclient()); if (build.version.sdk_int < 8) { ... } else { webview.getsettings().setpluginstate(websettings.pluginstate.on); } webview.loadurl("www.example.com.");

webviewclient

public class mywebclient extends webviewclient { @override public void onpagestarted(webview view, string url, bitmap favicon) { super.onpagestarted(view, url, favicon); } public void onloadresource (webview view, string url) { } @override public void onreceivederror(webview view, int errorcode, string description, string failingurl) { webview.loadurl("file:///android_asset/myerrorpage.html"); } public boolean shouldoverrideurlloading(webview view, string url) { // todo auto-generated method stub progress.setvisibility(view.visible); view.loadurl(url); homecoming true; } @override public void onpagefinished(webview view, string url) { super.onpagefinished(view, url); progress.setvisibility(view.gone); } }

you must override shouldoverrideurlloading() method in webviewclient class , next code

@override public boolean shouldoverrideurlloading(webview view, string url) { if (uri.parse(url).gethost().equals("www.example.com")) { // web site, not override; allow webview load page homecoming false; } // otherwise, link not page on site, launch activity handles urls intent intent = new intent(intent.action_view, uri.parse(url)); startactivity(intent); homecoming true; }

go through the documentation more information.

android webview

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -