Skip to content

Instantly share code, notes, and snippets.

@j-onathan
Created August 20, 2014 08:36
Show Gist options
  • Save j-onathan/ad8429c5ba38c57dc46f to your computer and use it in GitHub Desktop.
Save j-onathan/ad8429c5ba38c57dc46f to your computer and use it in GitHub Desktop.
public static Intent createYoutubeIntent(MovieBean movie) {
Builder youtubeUri = new Builder();
youtubeUri.scheme("http");
youtubeUri.authority("m.youtube.com");
youtubeUri.path("results");
youtubeUri.appendQueryParameter("q", new StringBuilder("\"").append(movie.getMovieName()).append("\" trailer").toString());
StringBuilder youtubeUriStr = new StringBuilder("http://m.youtube.com/results?q=");
youtubeUriStr.append(new StringBuilder("\"").append(Uri.encode(movie.getMovieName())).append("\"+trailer").toString());
Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(youtubeUriStr.toString()));
return myIntent;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment