문제

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...

도움이 되었습니까?

해결책

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;
    }
}

다른 팁

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

You can also try like this.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top