title: Get video url from Facebook in WebView
body: <p>I need to download video from Facebook. In order to download video i need video url from <code>Webview</code> where i am loading the Facebook Page and user get login
  I have tried following approaches to achieve this but none of its work</p>
  
  <p><strong>1.</strong><a href="https://stackoverflow.com/questions/10069050/download-file-inside-webview">Link 1</a></p>
  
  <p><strong>2.</strong><a href="https://stackoverflow.com/questions/21864098/how-to-download-files-from-webview-android">Link 2</a></p>
  
  <p>I tried to get video tag from html in webview but it didnt work because when we click on video on webview we are not able to get any html string</p>
  
  <p>Following is the code i have tried so far in <code>WebViewActivity</code></p>
  
  <pre><code>        public class WebViewActivity extends BaseActivity {
              private static final String TAG = WebViewActivity.class.getSimpleName();
  
              @Override
              protected void onCreate(@Nullable Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
  
                  WebView webview = new WebView(this);
                  webview.setWebChromeClient(new WebChromeClient());
                  WebViewClient client = new ChildBrowserClient();
                  webview.setWebViewClient(client);
                  WebSettings settings = webview.getSettings();
                  settings.setJavaScriptEnabled(true);
                  webview.setInitialScale(1);
                  webview.getSettings().setUseWideViewPort(true);
                  settings.setJavaScriptCanOpenWindowsAutomatically(false);
                  settings.setBuiltInZoomControls(true);
                  settings.setPluginState(WebSettings.PluginState.ON);
                  settings.setDomStorageEnabled(true);
                  webview.loadUrl("http://m.facebook.com");
                  webview.setId(5);
                  webview.setInitialScale(0);
                  webview.requestFocus();
                  webview.requestFocusFromTouch();
                  setContentView(webview);
              }
  
           public class ChildBrowserClient extends WebViewClient {
              @SuppressLint("InlinedApi")
              @Override
              public boolean shouldOverrideUrlLoading(WebView view, String url) {
                  boolean value = true;
                  String extension = MimeTypeMap.getFileExtensionFromUrl(url);
                  if (extension != null) {
                      MimeTypeMap mime = MimeTypeMap.getSingleton();
                      String mimeType = mime.getMimeTypeFromExtension(extension);
                      if (mimeType != null) {
                          if (mimeType.toLowerCase().contains("video")
                                  || extension.toLowerCase().contains("mov")
                                  || extension.toLowerCase().contains("mp4")) {
                              DownloadManager mdDownloadManager = (DownloadManager) WebViewActivity.this
                                      .getSystemService(Context.DOWNLOAD_SERVICE);
                              DownloadManager.Request request = new DownloadManager.Request(
                                      Uri.parse(url));
                              File destinationFile = new File(
                                      Environment.getExternalStorageDirectory(),
                                      getFileName(url));
                              request.setDescription("Downloading via Your app name..");
                              request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                              request.setDestinationUri(Uri.fromFile(destinationFile));
                              mdDownloadManager.enqueue(request);
                              value = false;
                          }
                      }
                      if (value) {
                          view.loadUrl(url);
                      }
                  }
                  return value;
              }
  
              @Override
              public void onPageFinished(WebView view, String url) {
                  super.onPageFinished(view, url);
              }
  
              /**
               * Notify the host application that a page has started loading.
               *
               * @param view The webview initiating the callback.
               * @param url  The url of the page.
               */
              @Override
              public void onPageStarted(WebView view, String url, Bitmap favicon) {
                  super.onPageStarted(view, url, favicon);
              }
          }
  
          /**
           * File name from URL
           *
           * @param url
           * @return
           */
          public String getFileName(String url) {
              String filenameWithoutExtension = "";
              filenameWithoutExtension = String.valueOf(System.currentTimeMillis()
                      + ".mp4");
              return filenameWithoutExtension;
          }
   }
  </code></pre>
  
  <p>Any Help will be appreciated !!</p>