Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Url open in full screen instead of Webview

I am working on an Android project, and my task is to open a url in an embedded webview. Here is the code. When a button is clicked I open the url as follows:

    yookosBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            linearLayout.setVisibility(View.GONE);
            webview.setVisibility(View.VISIBLE);
            webview.loadUrl("https://www.google.com.pk/");              
        }
    });

1: When i open the google.com it is perfectly opened in embedded webview:

enter image description here

But when I replace the link with "http://videoshare.loveworldapis.com/commentredirect.php" url, the link is opened in full screen instead of embedded portion of webview as shown below:

enter image description here

Can you tell me what modification should I do to open the second website into embedded webview instead of full screen.

like image 300
Muhammad Nabeel Arif Avatar asked Jan 17 '23 05:01

Muhammad Nabeel Arif


1 Answers

The WebView, by default, will open successive URLs by firing an intent, and opening the browser. To disable it so all URLs load in the WebView do this:

webView.setWebViewClient(new WebViewClient()       
    {
         @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) 
        {
            return false;
        }
    });

I suspect your web site load involves an HTTP redirect, and that redirect is causing the browser to open.

like image 197
Ollie C Avatar answered Jan 20 '23 14:01

Ollie C