Pregunta

I'm quite novice to android development. I tried several methods that have been found by googling and they all just fizzled out. So, can anyone help me how to clear that problem? I'll be so grateful...

¿Fue útil?

Solución

startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.youtube.com/watch?v=B1g_ouW6Tos")));

is enough for that operation.

Edit: If you want to add webview use that example; Add your layout a webview;

<WebView
    android:id="@+id/webView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />

Then in your class add this codes;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    WebView webView = (WebView) findViewById(R.id.webView);
    WebSettings settings = webView.getSettings();
    settings.setLoadWithOverviewMode(true);
    settings.setUseWideViewPort(true);
    detailView.setWebViewClient(new Client());
    detailView.loadUrl("http://www.youtube.com/watch?v=B1g_ouW6Tos");
}
private class Client extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }
}

Otros consejos

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube://" + video_id);
startActivity(intent);

You can also try like this.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top