Created
January 13, 2018 16:41
-
-
Save sreeprasad/2e7d27b7418a8980ad99b92df83748f7 to your computer and use it in GitHub Desktop.
Shows how to create a URL
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
| final static String GITHUB_BASE_URL = | |
| "https://api.github.com/search/repositories"; | |
| final static String PARAM_QUERY = "q"; | |
| final static String PARAM_SORT = "sort"; | |
| final static String sortBy = "stars"; | |
| public static URL buildUrl(String githubSearchQuery) { | |
| Uri uri = Uri.parse(GITHUB_BASE_URL) | |
| .buildUpon() | |
| .appendQueryParameter(PARAM_QUERY,githubSearchQuery) | |
| .appendQueryParameter(PARAM_SORT, sortBy) | |
| .build(); | |
| URL queryURL = null; | |
| try { | |
| queryURL = new URL(uri.toString()); | |
| }catch (MalformedURLException e) { | |
| e.printStackTrace(); | |
| } | |
| return queryURL; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment