private String appendParametersToBaseUrl(String baseUrl, Boolean isBatch) { if (!isBatch && httpMethod == HttpMethod.POST) { return baseUrl; } Uri.Builder uriBuilder = Uri.parse(baseUrl).buildUpon(); Set<String> keys = this.parameters.keySet(); for (String key : keys) { Object value = this.parameters.get(key); if (value == null) { value = ""; } if (isSupportedParameterType(value)) { value = parameterToString(value); } else { if (httpMethod == HttpMethod.GET) { throw new IllegalArgumentException( String.format( Locale.US, "Unsupported parameter type for GET request: %s", value.getClass().getSimpleName())); } continue; } uriBuilder.appendQueryParameter(key, value.toString()); } return uriBuilder.toString(); }
@Override public String syncURL() { // Allow user to specify custom sync server SharedPreferences userPreferences = AnkiDroidApp.getSharedPrefs(AnkiDroidApp.getInstance()); if (userPreferences!= null && userPreferences.getBoolean("useCustomSyncServer", false)) { Uri syncBase = Uri.parse(userPreferences.getString("syncBaseUrl", Consts.SYNC_BASE)); return syncBase.buildUpon().appendPath("sync").toString() + "/"; } // Usual case return Consts.SYNC_BASE + "sync/"; }
public String syncURL() { // Allow user to specify custom sync server SharedPreferences userPreferences = AnkiDroidApp.getSharedPrefs(AnkiDroidApp.getInstance()); if (userPreferences!= null && userPreferences.getBoolean("useCustomSyncServer", false)) { Uri syncBase = Uri.parse(userPreferences.getString("syncBaseUrl", Consts.SYNC_BASE)); return syncBase.buildUpon().appendPath("sync").toString() + "/"; } // Usual case return Consts.SYNC_BASE + "sync/"; } }
URL url = new URL(uri.toString()); DocumentBuilderFactory dbf = DocumentBuilderFactory .newInstance();
String injectJsUrl = uri.buildUpon().path(JM_LOCAL_COLLECTOR_JS_PATH).toString();
private String buildurl(Uri paramUri) { // Uri localUri; Uri.Builder localBuilder = new Uri.Builder(); if (TextUtils.isEmpty(paramUri.getQuery())) { localBuilder = paramUri.buildUpon(); } for (String str1 = "0"; ; str1 = "1") { localBuilder.appendQueryParameter("countryid", str1). appendQueryParameter("belongid", "0");//String.valueOf(q.a().g().id) Iterator localIterator = paramUri.getQueryParameterNames().iterator(); while (localIterator.hasNext()) { String str2 = (String) localIterator.next(); if (("countryid".equals(str2)) || ("belongid".equals(str2))) continue; localBuilder.appendQueryParameter(str2, paramUri.getQueryParameter(str2)); } // localUri = Uri.parse(paramUri.toString().replace(paramUri.getQuery(), "")); break; } return localBuilder.toString(); }
private String appendParametersToBaseUrl(String baseUrl) { Uri.Builder uriBuilder = new Uri.Builder().encodedPath(baseUrl); Set<String> keys = this.parameters.keySet(); for (String key : keys) { Object value = this.parameters.get(key); if (value == null) { value = ""; } if (isSupportedParameterType(value)) { value = parameterToString(value); } else { if (httpMethod == HttpMethod.GET) { throw new IllegalArgumentException(String.format("Unsupported parameter type for GET request: %s", value.getClass().getSimpleName())); } continue; } uriBuilder.appendQueryParameter(key, value.toString()); } return uriBuilder.toString(); }
public static URI getProfilePictureUrl( String userId, int width, int height) throws URISyntaxException { Validate.notNullOrEmpty(userId, "userId"); width = Math.max(width, UNSPECIFIED_DIMENSION); height = Math.max(height, UNSPECIFIED_DIMENSION); if (width == UNSPECIFIED_DIMENSION && height == UNSPECIFIED_DIMENSION) { throw new IllegalArgumentException("Either width or height must be greater than 0"); } Uri.Builder builder = new Uri.Builder().encodedPath(String.format(PROFILEPIC_URL_FORMAT, userId)); if (height != UNSPECIFIED_DIMENSION) { builder.appendQueryParameter(HEIGHT_PARAM, String.valueOf(height)); } if (width != UNSPECIFIED_DIMENSION) { builder.appendQueryParameter(WIDTH_PARAM, String.valueOf(width)); } builder.appendQueryParameter(MIGRATION_PARAM, MIGRATION_VALUE); return new URI(builder.toString()); }
@Override public void success(String responseBody) { final PayPalPaymentResource paypalPaymentResource; try { paypalPaymentResource = PayPalPaymentResource.fromJson(responseBody); } catch (JSONException e) { fragment.postCallback(e); return; } String redirectUrl = Uri.parse(paypalPaymentResource.getRedirectUrl()) .buildUpon() .appendQueryParameter(USER_ACTION_KEY, paypalRequest.getUserAction()) .toString(); Request request; if (isBillingAgreement) { request = getBillingAgreementRequest(fragment, redirectUrl); } else { request = getCheckoutRequest(fragment, redirectUrl); } startPayPal(fragment, request, handler); }
/** * Gets the request url. * * @return The request url. */ @Override public URL getRequestUrl() { String requestUrl = addFunctionParameters(); Uri baseUrl = Uri.parse(requestUrl); final Uri.Builder uriBuilder = baseUrl.buildUpon(); for (final QueryOption option : mQueryOptions) { uriBuilder.appendQueryParameter(option.getName(), option.getValue().toString()); } try { return new URL(uriBuilder.toString()); } catch (final MalformedURLException e) { throw new ClientException("Invalid URL: " + uriBuilder.toString(), e, GraphErrorCodes.InvalidRequest); } }
public String reviseImageUrl(final Integer displayWidth, final Integer displayHeight, final String originalImageUrl) { final String revisedImageUrl; if (displayWidth == null && displayHeight == null) { revisedImageUrl = originalImageUrl; } else { final Uri.Builder uriBuilder = Uri.parse(originalImageUrl).buildUpon(); if (displayWidth != null && displayWidth > 0) { uriBuilder.appendQueryParameter(QUERY_KEY_DISPLAY_WIDTH, String.valueOf(displayWidth)); } if (displayHeight != null && displayHeight > 0) { uriBuilder.appendQueryParameter(QUERY_KEY_DISPLAY_HEIGHT, String.valueOf(displayHeight)); } revisedImageUrl = uriBuilder.toString(); } return revisedImageUrl; } final String newImageUlr = reviseImageUrl(displySize.x, displySize.y, urlSource);
import android.net.Uri; ... private String getParams(String queryStr) { Uri.Builder builder = new Uri.Builder(); builder.appendQueryParameter("your_parameter_key", queryStr); return builder.toString(); }
@Override public Loader<List<News>> onCreateLoader(int i, Bundle bundle) { mLoadingIndicator.setVisibility(View.VISIBLE); mRecyclerView.setVisibility(View.GONE); Uri baseUri = Uri.parse(NEWS_REQUEST_URL); Uri.Builder uriBuilder = baseUri.buildUpon(); uriBuilder.appendQueryParameter("api-key", "31348b4c-ec34-4a51-98d4-dfc8471f2a6c"); if(mSearchQuery!=null) uriBuilder.appendQueryParameter("q", mSearchQuery); return new NewsLoader(this, uriBuilder.toString()); }
Uri.Builder builder = new Uri.Builder(); builder.scheme("http") .authority("api.openweathermap.org") .appendPath("data") .appendPath("2.5") .appendPath("forecast") .appendPath("daily") .appendQueryParameter("zip", "94043") .appendQueryParameter("mode", "json") .appendQueryParameter("units", "metric") .appendQueryParameter("cnt", "7"); String formURL = builder.toString();
protected void onPostExecute(String[] result) { Uri.Builder url_for_poster = new Uri.Builder(); ArrayList<String> uriPaths = imag_adap.getUriList(); uriPaths.clear(); for (int j = 0; j < count; j++) { String pos_sin_path = pos_path[j]; Uri.Builder url_build = url_for_poster.scheme("http").authority("image.tmdb.org/t/p").appendPath("w92").appendPath("pos_sin_path"); String url = url_build.toString(); uriPaths.add(url); } imag_adap.notifyDataSetChanged(); }
public static Uri getFacebookProfilePic(String fbId,int height, int width) { Uri.Builder builder = new Uri.Builder().encodedPath(String.format("https://graph.facebook.com/%s/picture", fbId)); builder.appendQueryParameter("height", String.valueOf(height)); builder.appendQueryParameter("width", String.valueOf(width)); builder.appendQueryParameter("migration_overrides", "{october_2012:true}"); return Uri.parse(builder.toString()); }
private static final String URL="https://www.example.com"; private static final String PATH = "test"; private static final String PARAM_MYID = "myid"; public static String buildMyUrl(String id){ Uri.Builder b = Uri.parse(URL).buildUpon(); b.path(PATH); b.appendQueryParameter(PARAM_MYID, id); b.build(); return b.toString(); }
if(!TextUtils.isEmpty(mBundleUrl)){ try { performance.args= Uri.parse(mBundleUrl).buildUpon().clearQuery().toString(); } catch (Exception e) { performance.args=pageName;
private String wrapPageName(String pageName, String url) { if(TextUtils.equals(pageName, WXPerformance.DEFAULT)){ pageName=url; try { Uri uri=Uri.parse(url); if(uri!=null){ Uri.Builder builder=new Uri.Builder(); builder.scheme(uri.getScheme()); builder.authority(uri.getAuthority()); builder.path(uri.getPath()); pageName=builder.toString(); } } catch (Exception e) { } } return pageName; }