title: How to get link of youtube videos on click in WebView of Android Studio?
body: <p>I am building an app and the webview loads youtube.
  I want that when someone clicks on a video, it displays a toast containing the link which is clicked.</p>
  
  <p>I have tried using shouldOverrideUrlLoading and it works when clicked on on any url but not on youtube.</p>
  
  <p>What can the issue be ? Should i use javascript ?</p>
  
  <p>Any help is appreciated.</p>
  
  <p>The code i used follows -</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      WebView mywebview = (WebView)findViewById(R.id.webView);
      WebSettings webSettings = mywebview.getSettings();
      webSettings.setJavaScriptEnabled(true);
      mywebview.loadUrl("https://www.youtube.com");
      mywebview.setWebViewClient(new WebViewClient()
  
      {
  
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
  
              try {
  
                  // do whatever you want to do on a web link click
                 String hello = url;
  
                  Toast.makeText(MainActivity.this,hello,
                          Toast.LENGTH_SHORT).show();
  
              } catch (Exception e) {
                  e.printStackTrace();
              }
              return false;
          }
  
  
      });
  </code></pre>