title: unable to download the file from website loaded in android Webview
body: <p>I just working on a simple App which loads a website in the Webview. this app contains only webview nothing beyond that. Its purpose is to show the webpage as an app.</p>
  
  <p>When my app is opened, the website loads automatically and then navigation flow is working fine. </p>
  
  <p>Here comes the issue, few of my web pages contain download button. On download click, the files with following format <strong>".log , .txt, .pdf "</strong>  will be downloaded. </p>
  
  <p>When i load website in chrome / Mozilla in android browsers ,the download is working fine. But when I load webpage in the Webview of my app the download is not working.</p>
  
  <p>I connected my phone in debug mode for testing.In the log-cat console I see the below error on every download click in the Webview</p>
  
  <pre><code>12-04 10:47:27.689 7142-7142/com.myweb.mweb W/cr.BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 7142
  </code></pre>
  
  <p>Below is the MainActivity class</p>
  
  <pre><code>public class MYMainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_mymain);
  
          // clear webview db
          deleteDatabase("webview.db");
          deleteDatabase("webviewCache.db");
  
          // URL to load
          String url = "https://myweb.com";
          WebView myView = (WebView) findViewById(R.id.mywebview);
  
          // clear cache
          myView.clearCache(true);
          myView.clearHistory();
          CookieManager cookieManager = CookieManager.getInstance();
          cookieManager.removeAllCookies(null);
          cookieManager.flush();
  
          WebSettings webSettings = myView.getSettings();
          webSettings.setJavaScriptEnabled(true); // add java script support for webview
          webSettings.setDomStorageEnabled(true);
  
          // to download the files
          myView.setDownloadListener(new DownloadListener() {
              @Override
              public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
                  DownloadManager.Request request = new DownloadManager.Request(
                          Uri.parse(url));
  
                  request.allowScanningByMediaScanner();
                  request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); //Notify client once download is completed!
                  request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "Name of your downloadble file goes here, example: Mathematics II ");
                  DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
                  dm.enqueue(request);
                  Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); //This is important!
                  intent.addCategory(Intent.CATEGORY_OPENABLE); //CATEGORY.OPENABLE
                  intent.setType("*/*");//any application,any extension
                  Toast.makeText(getApplicationContext(), "Downloading File", //To notify the Client that the file is being downloaded
                          Toast.LENGTH_LONG).show();
              }
          });
  
          // Load only SSL URL and only Authenticated URL
          WebViewClient MyWebViewClient = new WebViewClient()
          {
              public boolean shouldOverrideUrlLoading(WebView view, String url) {
                  if (Uri.parse(url).getHost().endsWith("myweb.com") &amp;&amp;
                          (Uri.parse(url).getScheme().equalsIgnoreCase("https")))  {
                      // This is a trusted site, so do not override; let my WebView load the page
                      return false;
                  }
                  // Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs
                  // This is by default the Android Browser.
                  Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                  startActivity(intent);
                  return true;
              }
          };
  
          // set web client to not redirect and load in the same app opend
          myView.setWebViewClient(MyWebViewClient);
          //myView.setWebViewClient(new WebViewClient());
          myView.loadUrl(url);
  
      }
  }
  </code></pre>
  
  <p>and this is my Manifest .xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.myweb.mweb"&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER"/&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
      &lt;uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" /&gt;
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/my_logo"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity
              android:name=".MYMainActivity"
              android:label="@string/app_name"
              android:theme="@style/AppTheme.NoActionBar"
              android:configChanges="orientation|screenSize"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>why I am unable to download the file via webview.. guys help me out</p>