List of usage examples for android.net Uri toString
public abstract String toString();
From source file:com.andrewshu.android.reddit.common.util.Util.java
/** * @return mobile version of a wikipedia uri */// w w w .j av a 2s .c om static Uri createMobileWikpediaUri(Uri uri) { String uriString = uri.toString(); return Uri.parse(uriString.replace(".wikipedia.org/", ".m.wikipedia.org/")); }
From source file:cd.education.data.collector.android.utilities.WebUtils.java
public static final HttpHead createOpenRosaHttpHead(Uri u) { HttpHead req = new HttpHead(URI.create(u.toString())); setOpenRosaHeaders(req);//from w ww. j a va2 s .c o m return req; }
From source file:cd.education.data.collector.android.utilities.WebUtils.java
public static final HttpPost createOpenRosaHttpPost(Uri u) { HttpPost req = new HttpPost(URI.create(u.toString())); setOpenRosaHeaders(req);// www.ja v a2s . c om setGoogleHeaders(req); return req; }
From source file:org.ttrssreader.utils.Utils.java
public static String getTextFromClipboard(Context context) { // New Clipboard API ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); if (clipboard.hasPrimaryClip()) { if (!clipboard.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) return null; ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0); CharSequence chars = item.getText(); if (chars != null && chars.length() > 0) { return chars.toString(); } else {/*from ww w. j a va 2 s .c om*/ Uri pasteUri = item.getUri(); if (pasteUri != null) { return pasteUri.toString(); } } } return null; }
From source file:com.cloudbees.gasp.loader.RESTLoader.java
private static void attachUriWithQuery(HttpRequestBase request, Uri uri, Bundle params) { try {//ww w. j a v a 2 s .com if (params == null) { // No params were given or they have already been // attached to the Uri. request.setURI(new URI(uri.toString())); } else { Uri.Builder uriBuilder = uri.buildUpon(); // Loop through our params and append them to the Uri. for (BasicNameValuePair param : paramsToList(params)) { uriBuilder.appendQueryParameter(param.getName(), param.getValue()); } uri = uriBuilder.build(); request.setURI(new URI(uri.toString())); } } catch (URISyntaxException e) { Log.e(TAG, "URI syntax was incorrect: " + uri.toString()); } }
From source file:Main.java
/** * Gets the Uri to a specific audio file * @param filePath The path of the file that we are looking up * @param contentResolver The content resolver that is used to perform the query * @return The Uri of the sound file/*from www . j av a 2s. com*/ */ private static Uri getAudioUriFromFilePath(String filePath, ContentResolver contentResolver) { long audioId; Uri uri = MediaStore.Audio.Media.getContentUri("external"); String[] projection = { BaseColumns._ID }; Cursor cursor = contentResolver.query(uri, projection, MediaStore.MediaColumns.DATA + " LIKE ?", new String[] { filePath }, null); if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(projection[0]); audioId = cursor.getLong(columnIndex); cursor.close(); return Uri.parse(uri.toString() + "/" + audioId); } return null; }
From source file:com.google.sample.castcompanionlibrary.utils.Utils.java
/** * Returns the URL of an image for the {@link MediaInformation} at the given level. Level * should be a number between 0 and <code>n - 1</code> where <code>n</code> is the number of * images for that given item.//from w w w. j a va 2 s . com * * @param info * @param level * @return */ public static String getImageUrl(MediaInfo info, int level) { Uri uri = getImageUri(info, level); if (null != uri) { return uri.toString(); } return null; }
From source file:Main.java
public static String encodeQuery(String url) { Uri uri = Uri.parse(url); try {/*w w w. j a v a 2 s .com*/ String query = uri.getQuery(); String encodedQuery = query != null ? URLEncoder.encode(query, "UTF-8") : null; URI tmp = new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(), null, uri.getFragment()); return tmp + (encodedQuery != null && encodedQuery.length() > 0 ? "?" + encodedQuery : ""); } catch (UnsupportedEncodingException ignore) { } catch (URISyntaxException ignore) { } return uri.toString(); }
From source file:org.opendatakit.provider.FormsProviderUtils.java
public static ParsedFragment parseUri(Uri uri) throws UnsupportedEncodingException { String instanceId = null;//from www .j a v a 2s .c o m String screenPath = null; String auxillaryHash = null; // NOTE: uri.getFragment() un-escapes everything before returning the string // which is EXACTLY the wrong thing to do. String uriString = uri.toString(); String fragment = ""; int idxHash = uriString.indexOf("#"); if (idxHash >= 0) { fragment = uriString.substring(idxHash + 1); } if (!fragment.isEmpty()) { // and process the fragment to find the instanceId, screenPath and other // kv pairs String[] pargs = fragment.split("&"); boolean first = true; StringBuilder b = new StringBuilder(); int i; for (i = 0; i < pargs.length; ++i) { String[] keyValue = pargs[i].split("="); if ("instanceId".equals(keyValue[0])) { if (keyValue.length == 2) { instanceId = URLDecoder.decode(keyValue[1], ApiConstants.UTF8_ENCODE); } } else if ("screenPath".equals(keyValue[0])) { if (keyValue.length == 2) { screenPath = URLDecoder.decode(keyValue[1], ApiConstants.UTF8_ENCODE); } } else { // Ignore it if keyValue[0] is refId or formPath if (!("refId".equals(keyValue[0]) || "formPath".equals(keyValue[0]))) { if (!first) { b.append("&"); } first = false; b.append(pargs[i]); } } } String aux = b.toString(); if (aux.length() != 0) { auxillaryHash = aux; } } return new ParsedFragment(instanceId, screenPath, auxillaryHash); }
From source file:Main.java
public static Bitmap bitmapFromUri(Context context, Uri photoUri) throws FileNotFoundException, IOException { InputStream is = context.getContentResolver().openInputStream(photoUri); BitmapFactory.Options dbo = new BitmapFactory.Options(); dbo.inJustDecodeBounds = true;//from w w w . j a va2s . c o m BitmapFactory.decodeStream(is, null, dbo); is.close(); int rotatedWidth, rotatedHeight; int orientation = 0; if (photoUri.toString().contains("content:/")) { orientation = getOrientation(context, photoUri); Log.i("Photo Editor", "Orientation: " + orientation); } else { int orientationFormExif = getOrientationFromExif(photoUri, context); orientation = decodeExifOrientation(orientationFormExif); Log.i("Photo Editor", "Orientation form Exif: " + orientation); } if (orientation == 90 || orientation == 270) { rotatedWidth = dbo.outHeight; rotatedHeight = dbo.outWidth; } else { rotatedWidth = dbo.outWidth; rotatedHeight = dbo.outHeight; } Bitmap srcBitmap = readScaledBitmapFromUri(photoUri, context, rotatedWidth, rotatedHeight); srcBitmap = setProperOrientation(orientation, srcBitmap); return srcBitmap; }