List of usage examples for android.content ContentResolver SCHEME_ANDROID_RESOURCE
String SCHEME_ANDROID_RESOURCE
To view the source code for android.content ContentResolver SCHEME_ANDROID_RESOURCE.
Click Source Link
From source file:org.samcrow.ridgesurvey.TimerFragment.java
private void notifyHalfPeriod() { final Notification notification = new Builder(getContext()) .setContentTitle(getString(R.string.title_2_30_elapsed)) .setContentText(getString(R.string.content_2_30_elapsed)) .setSmallIcon(R.drawable.ic_timer_white_18dp) .setSound(Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getActivity().getPackageName() + "/raw/sound_notification_single")) .setAutoCancel(true).build(); mNotificationManager.notify(NOTIFICATION_HALF_PERIOD, notification); }
From source file:org.samcrow.ridgesurvey.TimerFragment.java
private void notifyStopped() { final Notification notification = new Builder(getContext()) .setContentTitle(getString(R.string.title_5_elapsed)) .setContentText(getString(R.string.content_5_elapsed)).setSmallIcon(R.drawable.ic_timer_white_18dp) .setAutoCancel(true).setSound(Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getActivity().getPackageName() + "/raw/sound_notification_double")) .build();//ww w.j a va 2 s . c o m mNotificationManager.cancel(NOTIFICATION_HALF_PERIOD); mNotificationManager.notify(NOTIFICATION_FULL_PERIOD, notification); }
From source file:com.sanparks.sanscan.WizardEntryActivity.java
void dispatchImageSourceSelected() { switch (_imageSource) { case RESOURCES: // We use special URI to load image from resources. _imageUri = Uri.parse(String.format("%s://%s/%d", ContentResolver.SCHEME_ANDROID_RESOURCE, getPackageName(), R.drawable.apple_touch_icon)); loadImage();// w ww . j ava 2s . co m break; case GALLERY: { final Intent intent = new Intent(this, PickImageActivity.class) .putExtra(PickImageActivity.KEY_FROM_CAMERA, false); this.startActivityForResult(intent, REQUEST_CODE_PICK_IMAGE); break; } case CAMERA: { final Intent intent = new Intent(this, PickImageActivity.class) .putExtra(PickImageActivity.KEY_FROM_CAMERA, true); this.startActivityForResult(intent, REQUEST_CODE_PICK_IMAGE); break; } default: return; } }
From source file:com.androidclub.source.XmlDocumentProvider.java
/** * Query data from the XML document referenced in the URI. * * <p>The XML document can be a local resource or a file that will be downloaded from the * Internet. In the latter case, your application needs to request the INTERNET permission in * its manifest.</p>//from w ww . java 2 s. co m * * The URI will be of the form <code>content://xmldocument/?resource=R.xml.myFile</code> for a * local resource. <code>xmldocument</code> should match the authority declared for this * provider in your manifest. Internet documents are referenced using * <code>content://xmldocument/?url=</code> followed by an encoded version of the URL of your * document (see {@link Uri#encode(String)}). * * <p>The number of columns of the resulting Cursor is equal to the size of the projection * array plus one, named <code>_id</code> which will contain a unique row id (allowing the * Cursor to be used with a {@link CursorAdapter}). The other columns' names are the projection * patterns.</p> * * @param uri The URI of your local resource or Internet document. * @param projection A set of patterns that will be used to extract data from each selected * node. See class documentation for pattern syntax. * @param selection A selection pattern which will select the nodes that will create the * Cursor's rows. See class documentation for pattern syntax. * @param selectionArgs This parameter is ignored. * @param sortOrder The row order in the resulting cursor is determined from the node order in * the XML document. This parameter is ignored. * @return A Cursor or null in case of error. */ @Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { XmlPullParser parser = null; mHttpClient = null; final String url = uri.getQueryParameter("url"); if (url != null) { parser = getUriXmlPullParser(url); } else { final String resource = uri.getQueryParameter("resource"); if (resource != null) { Uri resourceUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getContext().getPackageName() + "/" + resource); parser = getResourceXmlPullParser(resourceUri); } } if (parser != null) { XMLCursor xmlCursor = new XMLCursor(selection, projection); try { xmlCursor.parseWith(parser); return xmlCursor; } catch (IOException e) { Log.w(LOG_TAG, "I/O error while parsing XML " + uri, e); } catch (XmlPullParserException e) { Log.w(LOG_TAG, "Error while parsing XML " + uri, e); } finally { if (mHttpClient != null) { mHttpClient.close(); } } } return null; }
From source file:org.opensilk.video.util.Utils.java
public static Uri makeResourceUri(Context context, int resource) { return new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE).authority(context.getPackageName()) .appendPath(String.valueOf(resource)).build(); }
From source file:rocks.stalin.android.app.model.MusicProvider.java
private Collection<MediaBrowserCompat.MediaItem> createBrowsableMediaItemForRoot(Resources resources) { ArrayList<MediaBrowserCompat.MediaItem> rootMenuItems = new ArrayList<>(); rootMenuItems.add(new MediaBrowserCompat.MediaItem(new MediaDescriptionCompat.Builder() .setMediaId(MEDIA_ID_ALL_MUSICS).setTitle(resources.getString(R.string.browse_all)) .setSubtitle(resources.getString(R.string.browse_all_subtitle)) .setIconUri(new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) .authority(resources.getResourcePackageName(R.drawable.ic_allmusic_black_24dp)) .appendPath(resources.getResourceTypeName(R.drawable.ic_allmusic_black_24dp)) .appendPath(resources.getResourceEntryName(R.drawable.ic_allmusic_black_24dp)).build()) .build(), MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)); rootMenuItems.add(new MediaBrowserCompat.MediaItem(new MediaDescriptionCompat.Builder() .setMediaId(MEDIA_ID_MUSICS_BY_GENRE).setTitle(resources.getString(R.string.browse_genres)) .setSubtitle(resources.getString(R.string.browse_genre_subtitle)) .setIconUri(new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) .authority(resources.getResourcePackageName(R.drawable.ic_by_genre)) .appendPath(resources.getResourceTypeName(R.drawable.ic_by_genre)) .appendPath(resources.getResourceEntryName(R.drawable.ic_by_genre)).build()) .build(), MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)); return rootMenuItems; }
From source file:com.aengbee.android.leanback.ui.MainFragment.java
public static Uri resourceToUri(Context context, int resID) { return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + context.getResources().getResourcePackageName(resID) + '/' + context.getResources().getResourceTypeName(resID) + '/' + context.getResources().getResourceEntryName(resID)); }
From source file:com.afwsamples.testdpc.SetupManagementFragment.java
private static Uri resourceToUri(Context context, int resID) { return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + context.getResources().getResourcePackageName(resID) + '/' + context.getResources().getResourceTypeName(resID) + '/' + context.getResources().getResourceEntryName(resID)); }
From source file:android.support.v7.widget.SuggestionsAdapter.java
/** * Gets a drawable given a value provided by a suggestion provider. * * This value could be just the string value of a resource id * (e.g., "2130837524"), in which case we will try to retrieve a drawable from * the provider's resources. If the value is not an integer, it is * treated as a Uri and opened with// w ww . j a va 2 s .c om * {@link ContentResolver#openOutputStream(android.net.Uri, String)}. * * All resources and URIs are read using the suggestion provider's context. * * If the string is not formatted as expected, or no drawable can be found for * the provided value, this method returns null. * * @param drawableId a string like "2130837524", * "android.resource://com.android.alarmclock/2130837524", * or "content://contacts/photos/253". * @return a Drawable, or null if none found */ private Drawable getDrawableFromResourceValue(String drawableId) { if (drawableId == null || drawableId.length() == 0 || "0".equals(drawableId)) { return null; } try { // First, see if it's just an integer int resourceId = Integer.parseInt(drawableId); // It's an int, look for it in the cache String drawableUri = ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + mProviderContext.getPackageName() + "/" + resourceId; // Must use URI as cache key, since ints are app-specific Drawable drawable = checkIconCache(drawableUri); if (drawable != null) { return drawable; } // Not cached, find it by resource ID drawable = ContextCompat.getDrawable(mProviderContext, resourceId); // Stick it in the cache, using the URI as key storeInIconCache(drawableUri, drawable); return drawable; } catch (NumberFormatException nfe) { // It's not an integer, use it as a URI Drawable drawable = checkIconCache(drawableId); if (drawable != null) { return drawable; } Uri uri = Uri.parse(drawableId); drawable = getDrawable(uri); storeInIconCache(drawableId, drawable); return drawable; } catch (Resources.NotFoundException nfe) { // It was an integer, but it couldn't be found, bail out Log.w(LOG_TAG, "Icon resource not found: " + drawableId); return null; } }
From source file:cm.aptoide.com.actionbarsherlock.widget.SuggestionsAdapter.java
/** * Gets a drawable given a value provided by a suggestion provider. * * This value could be just the string value of a resource id * (e.g., "2130837524"), in which case we will try to retrieve a drawable from * the provider's resources. If the value is not an integer, it is * treated as a Uri and opened with//from w ww . j ava2 s . com * {@link ContentResolver#openOutputStream(android.net.Uri, String)}. * * All resources and URIs are read using the suggestion provider's context. * * If the string is not formatted as expected, or no drawable can be found for * the provided value, this method returns null. * * @param drawableId a string like "2130837524", * "android.resource://com.android.alarmclock/2130837524", * or "content://contacts/photos/253". * @return a Drawable, or null if none found */ private Drawable getDrawableFromResourceValue(String drawableId) { if (drawableId == null || drawableId.length() == 0 || "0".equals(drawableId)) { return null; } try { // First, see if it's just an integer int resourceId = Integer.parseInt(drawableId); // It's an int, look for it in the cache String drawableUri = ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + mProviderContext.getPackageName() + "/" + resourceId; // Must use URI as cache key, since ints are app-specific Drawable drawable = checkIconCache(drawableUri); if (drawable != null) { return drawable; } // Not cached, find it by resource ID drawable = mProviderContext.getResources().getDrawable(resourceId); // Stick it in the cache, using the URI as key storeInIconCache(drawableUri, drawable); return drawable; } catch (NumberFormatException nfe) { // It's not an integer, use it as a URI Drawable drawable = checkIconCache(drawableId); if (drawable != null) { return drawable; } Uri uri = Uri.parse(drawableId); drawable = getDrawable(uri); storeInIconCache(drawableId, drawable); return drawable; } catch (Resources.NotFoundException nfe) { // It was an integer, but it couldn't be found, bail out Log.w(LOG_TAG, "Icon resource not found: " + drawableId); return null; } }