that_person

Android Code Example: Uri.Builder (via http://goo.gl/gyTiKV)

Aug 20th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. public static Intent createYoutubeIntent(MovieBean movie) {
  2.     Builder youtubeUri = new Builder();
  3.     youtubeUri.scheme("http");
  4.     youtubeUri.authority("m.youtube.com");
  5.     youtubeUri.path("results");
  6.     youtubeUri.appendQueryParameter("q", new StringBuilder("\"").append(movie.getMovieName()).append("\" trailer").toString());
  7.  
  8.     StringBuilder youtubeUriStr = new StringBuilder("http://m.youtube.com/results?q=");
  9.     youtubeUriStr.append(new StringBuilder("\"").append(Uri.encode(movie.getMovieName())).append("\"+trailer").toString());
  10.     Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(youtubeUriStr.toString()));
  11.     return myIntent;
  12. }
Add Comment
Please, Sign In to add comment