How do I display a Youtube website / video in Webview?

I am a noob for Android, and I want to go to youtube.com and show the video from the site inside the web view. Currently, when I try to do this, the device browser appears and makes me navigate the site using the device browser. If the web view is not capable of such functions as placing the default browser for the device in your layout, since I would view the website so that the site can be viewed in the application. Any help is appreciated.

My code is:

huffingtonpost = (WebView)findViewById(R.id.webView1); huffingtonpost.getSettings().setJavaScriptEnabled(true); huffingtonpost.getSettings().setUseWideViewPort(true); huffingtonpost.getSettings().setLoadWithOverviewMode(true); try{ huffingtonpost.loadUrl("http://www.youtube.com/KitcoNews"); }catch (Exception e){ e.printStackTrace(); } 
+1
source share
1 answer

Take a look at β€œPage Handling,” which explains how to prevent Android from opening the default browser / stock. Quote below ...

When a user clicks a link from a web page in your web browser, the default behavior for Android launches an application that processes URLs. Typically, the default web browser opens and loads the destination URL. However, you can override this behavior for your WebView, so links open in your WebView.

0
source

All Articles