mercredi 26 août 2015

How to appear "No Connection" on android Web-View when there's no data connection?

I've wrote the code for viewing facebook site... but when there is no data connection through wifi or cellular network, on the webview it says web page not availabe and shows the website name as https://facebook.com... but what i'am wanting to show is "No Network" on the webview and and not to show the web site name. can u solve it for me please ?

//*Activity_Main starts here

@Override
 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //*Facebook site viewing*
    String url = "http://ift.tt/1LxcPZF";
    WebView view=(WebView)this.findViewById(R.id.webView);
    view.getSettings().setJavaScriptEnabled(true);
    view.loadUrl(url);
    view.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
        }
    });
    //*Facebook site viewing* ends here




Aucun commentaire:

Enregistrer un commentaire