private static Uri openMarketUrl(String packageName) { return Uri.parse("market://details") .buildUpon() .appendQueryParameter("id", packageName) .build(); }
private static Uri getGooglePlayUrl(String packageName) { return Uri.parse("https://play.google.com/store/apps/details") .buildUpon() .appendQueryParameter("id", packageName) .build(); }
@Override public String requestCustomSizeUrl(Integer width, Integer height) { if (baseImageUrl != null) { return baseImageUrl .buildUpon() .appendQueryParameter("width", width.toString()) .appendQueryParameter("height", height.toString()) .build() .toString(); } throw new RuntimeException("You have to set the base image url first"); } }
/** * Builds the URL used to query GitHub. * * @param githubSearchQuery The keyword that will be queried for. * @return The URL to use to query the GitHub server. */ public static URL buildUrl(String githubSearchQuery) { Uri builtUri = Uri.parse(GITHUB_BASE_URL).buildUpon() .appendQueryParameter(PARAM_QUERY, githubSearchQuery) .appendQueryParameter(PARAM_SORT, sortBy) .build(); URL url = null; try { url = new URL(builtUri.toString()); } catch (MalformedURLException e) { e.printStackTrace(); } return url; }
/** * This method is called when the Open Location in Map button is clicked. It will open the * a map to the location represented by the variable addressString using implicit Intents. * * @param v Button that was clicked. */ public void onClickOpenAddressButton(View v) { // COMPLETED (5) Store an address in a String String addressString = "1600 Amphitheatre Parkway, CA"; // COMPLETED (6) Use Uri.Builder with the appropriate scheme and query to form the Uri for the address Uri.Builder builder = new Uri.Builder(); builder.scheme("geo") .path("0,0") .appendQueryParameter("q", addressString); Uri addressUri = builder.build(); // COMPLETED (7) Replace the Toast with a call to showMap, passing in the Uri from the previous step showMap(addressUri); }
/** * This method is called when the Open Location in Map button is clicked. It will open the * a map to the location represented by the variable addressString using implicit Intents. * * @param v Button that was clicked. */ public void onClickOpenAddressButton(View v) { String addressString = "1600 Amphitheatre Parkway, CA"; Uri.Builder builder = new Uri.Builder(); builder.scheme("geo") .path("0,0") .appendQueryParameter("q", addressString); Uri addressUri = builder.build(); showMap(addressUri); }
public Uri build() { final Uri uri = mInternal ? mContentUriInternal : mContentUri; final Uri.Builder builder = uri.buildUpon(); if (mModule != null) { builder.appendPath(mModule); } if (mKey != null) { builder.appendPath(mKey); } if (mType != TrayStorage.Type.UNDEFINED) { builder.appendQueryParameter("backup", TrayStorage.Type.USER.equals(mType) ? "true" : "false"); } return builder.build(); }
private void handlePageList(LightHttpResponse response) throws JSONException { if (mPageListResponse == null) { JSONArray reply = new JSONArray(); JSONObject page = new JSONObject(); page.put("type", "app"); page.put("title", makeTitle()); page.put("id", PAGE_ID); page.put("description", ""); page.put("webSocketDebuggerUrl", "ws://" + mInspectorPath); Uri chromeFrontendUrl = new Uri.Builder() .scheme("http") .authority("chrome-devtools-frontend.appspot.com") .appendEncodedPath("serve_rev") .appendEncodedPath(WEBKIT_REV) .appendEncodedPath("devtools.html") .appendQueryParameter("ws", mInspectorPath) .build(); page.put("devtoolsFrontendUrl", chromeFrontendUrl.toString()); reply.put(page); mPageListResponse = LightHttpBody.create(reply.toString(), "application/json"); } setSuccessfulResponse(response, mPageListResponse); }
@Nullable public static Uri getUriForProvidedFile(@NonNull Context context, File file, @Nullable String encoding, @Nullable String mimeType) { try { Uri.Builder uriBuilder = FileProvider.getUriForFile(context, AUTHORITY, file).buildUpon(); if (mimeType != null) { uriBuilder.appendQueryParameter("mime_type", mimeType); } if (encoding != null) { uriBuilder.appendQueryParameter("encoding", encoding); } return uriBuilder.build(); } catch (IllegalArgumentException e) { return null; } }
public static Uri buildUri(String authority, String path, Bundle parameters) { Uri.Builder builder = new Uri.Builder(); builder.scheme(URL_SCHEME); builder.authority(authority); builder.path(path); if (parameters != null) { for (String key : parameters.keySet()) { Object parameter = parameters.get(key); if (parameter instanceof String) { builder.appendQueryParameter(key, (String) parameter); } } } return builder.build(); }
@Override public int insertNotes(long deckId, ContentValues[] valuesArr) { Uri.Builder builder = Note.CONTENT_URI.buildUpon(); builder.appendQueryParameter(Note.DECK_ID_QUERY_PARAM, String.valueOf(deckId)); return mResolver.bulkInsert(builder.build(), valuesArr); }
public static Uri getUserContentUri() { return getContentUri(TrayContract.Preferences.BASE_PATH).buildUpon() .appendQueryParameter("backup", "true") .build(); }
public static Uri getDeviceContentUri() { return getContentUri(TrayContract.Preferences.BASE_PATH).buildUpon() .appendQueryParameter("backup", "false") .build(); }
public static Uri getInternalUserContentUri() { return getContentUri(TrayContract.InternalPreferences.BASE_PATH).buildUpon() .appendQueryParameter("backup", "true") .build(); }
public static Uri getInternalDeviceContentUri() { return getContentUri(TrayContract.InternalPreferences.BASE_PATH).buildUpon() .appendQueryParameter("backup", "false") .build(); }
private void appendValue(IdentityField field, String value) { uri.appendQueryParameter(field.value(), value); }
/** * Removes query parameter from an Uri, if present. * * @param uri The uri. * @param queryParameterName The name of the query parameter. * @return The uri without the query parameter. */ public static Uri removeQueryParameter(Uri uri, String queryParameterName) { Uri.Builder builder = uri.buildUpon(); builder.clearQuery(); for (String key : uri.getQueryParameterNames()) { if (!key.equals(queryParameterName)) { for (String value : uri.getQueryParameters(key)) { builder.appendQueryParameter(key, value); } } } return builder.build(); }
public static Uri getMimeTypeUri(Uri contentUri, String mimeType) { if (!AUTHORITY.equals(contentUri.getAuthority())) { throw new IllegalArgumentException("Can only call this method for URIs within this authority!"); } if (contentUri.getQueryParameter("mime_type") != null) { throw new IllegalArgumentException("Can only call this method for not yet typed URIs!"); } return contentUri.buildUpon().appendQueryParameter("mime_type", mimeType).build(); }
/** * Converts the current board into a Uri. * @return a Uri that represents the current board. */ public Uri toUri() { Uri.Builder shareUri = SHARE_URI.buildUpon(); shareUri.appendQueryParameter(DATA_KEY, encodeBoard()); shareUri.appendQueryParameter(LOCKED_KEY, encodeLockedPositions()); return shareUri.build(); }
public static Uri buildUri(String filePath, boolean pipeMode) { Uri.Builder builder = new Uri.Builder() .scheme(ContentResolver.SCHEME_CONTENT) .authority(AUTHORITY) .path(filePath); if (pipeMode) { builder.appendQueryParameter(TestContentProvider.PARAM_PIPE_MODE, "1"); } return builder.build(); }