Created
August 20, 2014 08:36
-
-
Save j-onathan/ad8429c5ba38c57dc46f to your computer and use it in GitHub Desktop.
Android Code Example: Uri.Builder (from https://www.codota.com/android/scenarios/52fcbd69da0abb55b70a1bf7/android.net.Uri.Builder?tag=dragonfly)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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