10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

YouTubeの動画をYouTubeアプリで直接再生するIntentの書き方

Posted at

概要

アプリからYoutubeの動画へ遷移する時のメモ。
単純にIntent#setData()にパースした動画のURLを代入してもうまく動かなかったりする。

動画を直接表示

sample.java
String videoId = "<VIDEO_ID>";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("vnd.youtube:" + videoId);
intent.putExtra("VIDEO_ID", videoId);
startActivity(intent);

プレイリストを表示

sample.java
String playListUrl = "<PLAY_LIST_URL>";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.google.android.youtube");
intent.setData(Uri.parse(playListUrl));
startActivity(intent);
10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?