public static Uri getPhotoUri(File file, Context context) { Uri fileUri = Uri.fromFile(file); Uri.Builder builder = new Uri.Builder() .authority(getContentProviderAuthority(context)) .scheme("file") .path(fileUri.getPath()) .query(fileUri.getQuery()) .fragment(fileUri.getFragment()); return builder.build(); }
/** * Returns the URL with all but the last component of its path removed. This serves as a proxy * for scope until the scope manifest member is available. This method assumes that the URL * passed in is a valid URL with a path that contains at least one "/". * @param url The url to convert to a scope. * @return The scope. */ public static String getScopeFromUrl(String url) { Uri uri = Uri.parse(url); List<String> path = uri.getPathSegments(); int endIndex = path.size(); // If there is at least one path element, remove the last one. if (endIndex > 0) { endIndex -= 1; } // Make sure the path starts and ends with a slash (or is only a slash if there is no path). Uri.Builder builder = uri.buildUpon(); String scope_path = "/" + TextUtils.join("/", path.subList(0, endIndex)); if (scope_path.length() > 1) { scope_path += "/"; } builder.path(scope_path); // Clear out the query and fragment. builder.fragment(""); builder.query(""); return builder.build().toString(); }
assert url != null; newIntent.setData(new Uri.Builder().scheme(UrlConstants.CUSTOM_TAB_SCHEME) .authority(uuid).query(url).build());
.scheme(ContentResolver.SCHEME_CONTENT) .authority(authority) .query("") // TODO: Remove, workaround for a bug in Uri.writeToParcel() .fragment(""); // TODO: Remove, workaround for a bug in Uri.writeToParcel()
.scheme(ContentResolver.SCHEME_CONTENT) .authority(authority) .query("") // TODO: Remove, workaround for a bug in Uri.writeToParcel() .fragment(""); // TODO: Remove, workaround for a bug in Uri.writeToParcel()
.authority(uri.getAuthority()) .fragment(uri.getFragment()) .query(uri.getQuery());
public Builder buildUpon() { if (isHierarchical()) { return new Builder() .scheme(getScheme()) .authority(getAuthorityPart()) .path(getPathPart()) .query(getQueryPart()) .fragment(getFragmentPart()); } else { return new Builder() .scheme(getScheme()) .opaquePart(getSsp()) .fragment(getFragmentPart()); } } }
private Uri getShareURI() { final String mimeType = getShareMimeType(); Uri.Builder builder = new Uri.Builder(); Uri uri; if (scheme.temporary) { builder.scheme("content"); builder.authority("org.ebookdroid.document"); builder.path(m_fileName); builder.query(mimeType); uri = builder.build(); } else { builder.scheme("file"); builder.path(m_fileName); uri = builder.build(); } return uri; }
/** * 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") .query(addressString); Uri addressUri = builder.build(); showMap(addressUri); }
/** * Encodes and sets the query. */ public Builder query(String query) { return query(Part.fromDecoded(query)); }
public Builder buildUpon() { return new Builder() .scheme(scheme) .authority(authority) .path(path) .query(query) .fragment(fragment); } }
/** * Sets the previously encoded query. */ public Builder encodedQuery(String query) { return query(Part.fromEncoded(query)); }
/** * Clears the the previously set query. */ public Builder clearQuery() { return query((Part) null); }