Skip to content Skip to sidebar Skip to footer

Open Youtube App From Android Webview

I have an android app and hosting a web site under webview, i have a requirement to open youtube app from within the html of webview. I am trying with normal anchor link and it is

Solution 1:

1. If you own the webpage and links, you can simply add target parameter to the links like

<a href="https://www.youtube.com/video_id" **target="_blank"**>Open YouTube innewwindow</a>
  1. You can also override this method to intercept links in we view

    myWebView.setWebViewClient(newWebViewClient() { 
    @OverridepublicbooleanshouldOverrideUrlLoading(WebView view, String url) {  if(url.startsWith("www.youtube.Com") { 
     startActivity(newIntent(Intent.ACTION_VIEW, Uri.parse(url)));
      returntrue;}view.loadUrl(url); returnfalse; } }); 
    

Hope this helps.

Post a Comment for "Open Youtube App From Android Webview"