List of usage examples for android.net Uri getAuthority
@Nullable public abstract String getAuthority();
From source file:com.google.android.gm.ay.java
public static boolean g(final Context context, final Uri uri) { final String a = c.a(context.getContentResolver(), "gmail-ad-youtube-partial-authority", "youtube.com"); final String a2 = c.a(context.getContentResolver(), "gmail-ad-youtube-path", "/watch"); final String authority = uri.getAuthority(); final String path = uri.getPath(); return authority != null && path != null && authority.endsWith(a) && a2.equals(path); }
From source file:com.jefftharris.passwdsafe.file.PasswdFileUri.java
/** Get the URI type */ private static Type getUriType(Uri uri) { if (uri.getScheme().equals(ContentResolver.SCHEME_FILE)) { return Type.FILE; }//from ww w . j a v a 2s. c o m String auth = uri.getAuthority(); if (PasswdSafeContract.AUTHORITY.equals(auth)) { return Type.SYNC_PROVIDER; } else if (auth.contains("mail")) { return Type.EMAIL; } return Type.GENERIC_PROVIDER; }
From source file:com.applozic.mobicommons.file.FileUtils.java
/** * @param uri The Uri to check./*from w ww .j a v a 2 s . c o m*/ * @return Whether the Uri authority is {@link LocalStorageProvider}. * @author paulburke */ public static boolean isLocalStorageDocument(Uri uri) { return LocalStorageProvider.AUTHORITY.equals(uri.getAuthority()); }
From source file:com.just.agentweb.AgentWebUtils.java
/** * @param uri The Uri to check./* ww w . j a v a 2s . c o m*/ * @return Whether the Uri authority is ExternalStorageProvider. */ static boolean isExternalStorageDocument(Uri uri) { return "com.android.externalstorage.documents".equals(uri.getAuthority()); }
From source file:com.just.agentweb.AgentWebUtils.java
/** * @param uri The Uri to check./*from w w w . j a v a 2s . c om*/ * @return Whether the Uri authority is MediaProvider. */ static boolean isMediaDocument(Uri uri) { return "com.android.providers.media.documents".equals(uri.getAuthority()); }
From source file:com.just.agentweb.AgentWebUtils.java
/** * @param uri The Uri to check.// w w w. j a v a 2 s . c om * @return Whether the Uri authority is Google Photos. */ static boolean isGooglePhotosUri(Uri uri) { return "com.google.android.apps.photos.content".equals(uri.getAuthority()); }
From source file:com.just.agentweb.AgentWebUtils.java
/** * @param uri The Uri to check./* w ww . j a v a 2 s . c om*/ * @return Whether the Uri authority is DownloadsProvider. */ static boolean isDownloadsDocument(Uri uri) { return "com.android.providers.downloads.documents".equals(uri.getAuthority()); }
From source file:com.applozic.mobicommons.file.FileUtils.java
/** * Get a file path from a Uri. This will get the the path for Storage Access * Framework Documents, as well as the _data field for the MediaStore and * other file-based ContentProviders.<br> * <br>//w w w . j av a2 s . c o m * Callers should check whether the path is local before assuming it * represents a local file. * * @param context The context. * @param uri The Uri to query. * @author paulburke * @see #isLocal(String) * @see #getFile(android.content.Context, android.net.Uri) */ public static String getPath(final Context context, final Uri uri) { if (DEBUG) Log.d(TAG + " File -", "Authority: " + uri.getAuthority() + ", Fragment: " + uri.getFragment() + ", Port: " + uri.getPort() + ", Query: " + uri.getQuery() + ", Scheme: " + uri.getScheme() + ", Host: " + uri.getHost() + ", Segments: " + uri.getPathSegments().toString()); final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; // DocumentProvider if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) { // LocalStorageProvider if (isLocalStorageDocument(uri)) { // The path is the id return DocumentsContract.getDocumentId(uri); } // ExternalStorageProvider else if (isExternalStorageDocument(uri)) { final String docId = DocumentsContract.getDocumentId(uri); final String[] split = docId.split(":"); final String type = split[0]; if ("primary".equalsIgnoreCase(type)) { return Environment.getExternalStorageDirectory() + "/" + split[1]; } // TODO handle non-primary volumes } // DownloadsProvider else if (isDownloadsDocument(uri)) { final String id = DocumentsContract.getDocumentId(uri); final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); return getDataColumn(context, contentUri, null, null); } // MediaProvider else if (isMediaDocument(uri)) { final String docId = DocumentsContract.getDocumentId(uri); final String[] split = docId.split(":"); final String type = split[0]; Uri contentUri = null; if ("image".equals(type)) { contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; } else if ("video".equals(type)) { contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; } else if ("audio".equals(type)) { contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; } final String selection = "_id=?"; final String[] selectionArgs = new String[] { split[1] }; return getDataColumn(context, contentUri, selection, selectionArgs); } } // MediaStore (and general) else if ("content".equalsIgnoreCase(uri.getScheme())) { // Return the remote address if (isGooglePhotosUri(uri)) return uri.getLastPathSegment(); return getDataColumn(context, uri, null, null); } // File else if ("file".equalsIgnoreCase(uri.getScheme())) { return uri.getPath(); } return null; }
From source file:com.tct.mail.providers.Attachment.java
public static boolean isDownloadsUri(Uri uri) { return "downloads".equals(uri.getAuthority()); }
From source file:air.com.snagfilms.utils.Utils.java
public static Map<String, String> getReferrerMapFromUri(Uri uri) { MapBuilder paramMap = new MapBuilder(); // If no URI, return an empty Map. if (uri == null) { return paramMap.build(); }/*from www.j a v a 2 s .com*/ // Source is the only required campaign field. No need to continue if // not // present. if (uri.getQueryParameter(AnalyticsAPI.CAMPAIGN_SOURCE_PARAM) != null) { // MapBuilder.setCampaignParamsFromUrl parses Google Analytics // campaign // ("UTM") parameters from a string URL into a Map that can be set // on // the Tracker. paramMap.setCampaignParamsFromUrl(uri.toString()); // If no source parameter, set authority to source and medium to // "referral". } else if (uri.getAuthority() != null) { paramMap.set(Fields.CAMPAIGN_MEDIUM, "referral"); paramMap.set(Fields.CAMPAIGN_SOURCE, uri.getAuthority()); } return paramMap.build(); }