List of usage examples for android.net Uri toString
public abstract String toString();
From source file:no.norrs.projects.andronary.utils.HttpUtil.java
public static HttpResponse DEL(final Uri uri) throws IOException { return DEL(uri.toString()); }
From source file:Main.java
@NonNull public static Intent openContent(@NonNull Uri uri) { final Intent intent = new Intent(Intent.ACTION_VIEW, uri); final String mime = URLConnection.guessContentTypeFromName(uri.toString()); if (!TextUtils.isEmpty(mime)) { intent.setType(mime);// ww w .j a v a2s. c o m } return intent; }
From source file:Main.java
public static String buildAccountName(Uri serverBaseUrl, String username) { if (serverBaseUrl.getScheme() == null) { serverBaseUrl = Uri.parse("https://" + serverBaseUrl.toString()); }/*from ww w . j a v a2 s . c o m*/ String accountName = username + "@" + serverBaseUrl.getHost(); if (serverBaseUrl.getPort() >= 0) { accountName += ":" + serverBaseUrl.getPort(); } return accountName; }
From source file:Main.java
@SuppressLint("NewApi") public static String uriToPath(Context activity, Uri uri) { if (null == uri) { return null; }/*from ww w. ja va 2s . c om*/ String urlStr = uri.toString(); if (urlStr.startsWith("file://")) { return uri.getPath(); } Cursor cursor = null; String idWhere; String id; String[] columns = { MediaStore.Images.Media.DATA }; try { if (Build.VERSION.SDK_INT == 19 && DocumentsContract.isDocumentUri(activity, uri)) { final String docId = DocumentsContract.getDocumentId(uri); final String[] split = docId.split(":"); id = split[1]; idWhere = MediaStore.Images.Media._ID + "=?"; cursor = activity.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, idWhere, new String[] { id }, null); } else { cursor = activity.getContentResolver().query(uri, columns, null, null, null); } if (cursor != null) { int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); if (cursor.moveToFirst()) { return cursor.getString(column_index); } } } catch (Exception e) { } finally { if (cursor != null) { cursor.close(); } } return null; }
From source file:Main.java
public static String buildAccountNameOld(Uri serverBaseUrl, String username) { if (serverBaseUrl.getScheme() == null) { serverBaseUrl = Uri.parse("https://" + serverBaseUrl.toString()); }/*w w w . j av a 2s.c o m*/ String accountName = username + "@" + serverBaseUrl.getHost(); if (serverBaseUrl.getPort() >= 0) { accountName += ":" + serverBaseUrl.getPort(); } return accountName; }
From source file:Main.java
public static boolean isPicture(File file) { Uri uri = Uri.fromFile(file); String type = MimeTypeMap.getSingleton() .getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(uri.toString())); if (type == null) return false; else/*from w ww . jav a 2s . c om*/ return (type.toLowerCase().startsWith("image/")); }
From source file:Main.java
static boolean isVideo(File file) { Uri uri = Uri.fromFile(file); String type = MimeTypeMap.getSingleton() .getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(uri.toString())); if (type == null) return false; else/* ww w .j a v a 2 s . c om*/ return (type.toLowerCase().startsWith("video/")); }
From source file:Main.java
private static String getUrl(String search) { Uri builtUri = Uri.parse(url).buildUpon().appendQueryParameter("q", search) .appendQueryParameter("maxResults", "20").build(); Log.d("DEBUG", builtUri.toString() + ". Search = " + search); return builtUri.toString(); }
From source file:Main.java
/** * Returns whether given ringtone uri is valid (will produce sound). Can be used to determine * validity of a ring tone uri which is retrieved from preferences. * * @param context {@link Context} used to access system data. * @param ringTone {@link Uri} for ring tone. * * @return true if there is a registered ring tone with given uri, false otherwise. *///w w w . j a v a 2s . c o m public static boolean isRingtoneValid(@NonNull Context context, @NonNull Uri ringTone) { Map<String, String> ringTones = getRingtones(context); return (ringTones.values().contains(ringTone.toString())); }
From source file:Main.java
public static Map<String, String> deferredDeeplinkToMap(Uri uri) { HashMap<String, String> map = new HashMap<String, String>(); if (null == uri) { return map; }/*from w w w . j a v a 2s . c o m*/ map.put("uri", uri.toString()); return map; }