List of usage examples for android.net Uri buildUpon
public abstract Builder buildUpon();
From source file:com.silentcircle.contacts.utils.HelpUtils.java
/** * Adds two query parameters into the Uri, namely the language code and the version code * of the app's package as gotten via the context. * @return the uri with added query parameters *//*from w w w . j a v a 2 s . c om*/ private static Uri uriWithAddedParameters(Context context, Uri baseUri) { Uri.Builder builder = baseUri.buildUpon(); // Add in the preferred language builder.appendQueryParameter(PARAM_LANGUAGE_CODE, Locale.getDefault().toString()); // Add in the package version code if (sCachedVersionCode == null) { // There is no cached version code, so try to get it from the package manager. try { // cache the version code PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); sCachedVersionCode = Integer.toString(info.versionCode); // append the version code to the uri builder.appendQueryParameter(PARAM_VERSION, sCachedVersionCode); } catch (NameNotFoundException e) { // Cannot find the package name, so don't add in the version parameter // This shouldn't happen. Log.wtf(TAG, "Invalid package name for context", e); } } else { builder.appendQueryParameter(PARAM_VERSION, sCachedVersionCode); } // Build the full uri and return it return builder.build(); }
From source file:at.bitfire.ical4android.AndroidTaskList.java
public static Uri syncAdapterURI(Uri uri, Account account) { return uri.buildUpon().appendQueryParameter(TaskContract.ACCOUNT_NAME, account.name) .appendQueryParameter(TaskContract.ACCOUNT_TYPE, account.type) .appendQueryParameter(TaskContract.CALLER_IS_SYNCADAPTER, "true").build(); }
From source file:edu.mit.mobile.android.locast.data.Locatable.java
/** * Makes a URI that queries the locatable item by distance. * * @param contentUri/* w w w. ja va 2 s . com*/ * the GeoPoint content URI to build upon. Must be a dir, not an item. * @param location * center point * @param distance * distance in meters * @return */ public static Uri toDistanceSearchUri(Uri contentUri, GeoPoint location, double distance) { return contentUri.buildUpon() .appendQueryParameter(SERVER_QUERY_PARAMETER, location.getLongitudeE6() / 1E6f + "," + location.getLatitudeE6() / 1E6f + "," + distance) .build(); }
From source file:at.bitfire.ical4android.AndroidCalendar.java
public static Uri syncAdapterURI(Uri uri, Account account) { return uri.buildUpon().appendQueryParameter(Calendars.ACCOUNT_NAME, account.name) .appendQueryParameter(Calendars.ACCOUNT_TYPE, account.type) .appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true").build(); }
From source file:org.LinuxdistroCommunity.android.client.NetworkUtilities.java
private static URL getRequestURL(String server, String uri, ArrayList<NameValuePair> params) throws MalformedURLException { Uri server_uri = Uri.parse(server + uri); Uri.Builder request_builder = server_uri.buildUpon(); for (NameValuePair item : params) { request_builder.appendQueryParameter(item.getName(), item.getValue()); }//from w ww . j a v a2s . c o m request_builder.appendQueryParameter(PARAM_CLIENT_ID, CLIENT_ID); return new URL(request_builder.toString()); }
From source file:edu.stanford.mobisocial.dungbeetle.social.FriendRequest.java
public static void sendFriendRequest(Context context, long contactId, String capability) { Maybe<Contact> contactSortOf = Contact.forId(context, contactId); try {/*w w w . j a v a2 s. co m*/ Contact contact = contactSortOf.get(); Uri uri = getInvitationUri(context, false); if (capability != null) { uri = uri.buildUpon().appendQueryParameter("cap", capability).build(); } DbObject obj = FriendAcceptObj.from(uri); Helpers.sendMessage(context, contact, obj); if (DBG) Log.d(TAG, "Sent friend request uri " + uri); } catch (NoValError e) { Log.e(TAG, "Could not locate contact " + contactId); } }
From source file:org.peterbaldwin.vlcremote.fragment.ArtFragment.java
private static Uri resizeJamendoImage(Uri uri) { String path = uri.getPath();/*w w w . j av a 2s . co m*/ path = path.replace("/" + uri.getLastPathSegment(), "/1.400.jpg"); return uri.buildUpon().path(path).build(); }
From source file:edu.mit.mobile.android.locast.data.interfaces.LocatableUtils.java
/** * Makes a URI that queries the locatable item by distance. * * @param contentUri/* ww w . j av a2 s . c o m*/ * the LocatableUtils content URI to build upon. Must be a dir, not an item. * @param location * center point * @param distance * distance in meters * @return */ public static Uri toDistanceSearchUri(Uri contentUri, Location location, double distance) { return contentUri.buildUpon().appendQueryParameter(SERVER_QUERY_PARAMETER, location.getLongitude() + "," + location.getLatitude() + "," + distance).build(); }
From source file:com.google.samples.apps.iosched.nearby.MetadataResolver.java
private static JsonObjectRequest createMetadataRequest(JSONObject jsonObj, final Map<String, NearbyDevice> deviceMap) { return new JsonObjectRequest(METADATA_URL, jsonObj, new Response.Listener<JSONObject>() { @Override/*from www .j ava 2 s . c o m*/ public void onResponse(JSONObject jsonResponse) { try { JSONArray foundMetaData = jsonResponse.getJSONArray("metadata"); int deviceCount = foundMetaData.length(); for (int i = 0; i < deviceCount; i++) { JSONObject deviceData = foundMetaData.getJSONObject(i); String title = "Unknown name"; String url = "Unknown url"; String description = "Unknown description"; String iconUrl = "/favicon.ico"; String id = deviceData.getString("id"); if (deviceData.has("title")) { title = deviceData.getString("title"); } if (deviceData.has("url")) { url = deviceData.getString("url"); } if (deviceData.has("description")) { description = deviceData.getString("description"); } if (deviceData.has("icon")) { // We might need to do some magic here. iconUrl = deviceData.getString("icon"); } // Provisions for a favicon specified as a relative URL. if (!iconUrl.startsWith("http")) { // Lets just assume we are dealing with a relative path. Uri fullUri = Uri.parse(url); Uri.Builder builder = fullUri.buildUpon(); // Append the default favicon path to the URL. builder.path(iconUrl); iconUrl = builder.toString(); } DeviceMetadata deviceMetadata = new DeviceMetadata(); deviceMetadata.title = title; deviceMetadata.description = description; deviceMetadata.siteUrl = url; deviceMetadata.iconUrl = iconUrl; downloadIcon(deviceMetadata, deviceMap.get(id)); // Look up the device from the input and update the data deviceMap.get(id).onDeviceInfo(deviceMetadata); } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { Log.i(TAG, "VolleyError: " + volleyError.toString()); } }); }
From source file:net.openid.appauth.AuthorizationServiceConfiguration.java
static Uri buildConfigurationUriFromIssuer(Uri openIdConnectIssuerUri) { return openIdConnectIssuerUri.buildUpon().appendPath(WELL_KNOWN_PATH) .appendPath(OPENID_CONFIGURATION_RESOURCE).build(); }