Java Code Examples for android.content.ContentResolver#SCHEME_ANDROID_RESOURCE

The following examples show how to use android.content.ContentResolver#SCHEME_ANDROID_RESOURCE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransferService.java    From nitroshare-android with MIT License 6 votes vote down vote up
/**
 * Create a bundle from the list of URIs
 * @param uriList list of URIs to add
 * @return newly created bundle
 */
private Bundle createBundle(ArrayList<Parcelable> uriList) throws IOException {
    Bundle bundle = new Bundle();
    for (Parcelable parcelable : uriList) {
        Uri uri = (Uri) parcelable;
        switch (uri.getScheme()) {
            case ContentResolver.SCHEME_ANDROID_RESOURCE:
            case ContentResolver.SCHEME_CONTENT:
                bundle.addItem(new FileItem(
                        getAssetFileDescriptor(uri),
                        getFilename(uri)
                ));
                break;
            case ContentResolver.SCHEME_FILE:
                File file = new File(uri.getPath());
                if (file.isDirectory()) {
                    traverseDirectory(file, bundle);
                } else {
                    bundle.addItem(new FileItem(file));
                }
                break;
        }
    }
    return bundle;
}
 
Example 2
Source File: NotificationBuilder.java    From AlexaAndroid with GNU General Public License v2.0 5 votes vote down vote up
/**
 * get uri to drawable or any other resource type if u wish
 * @param context - context
 * @param drawableId - drawable res id
 * @return - uri
 */
public static String getUriToDrawable(@NonNull Context context, @AnyRes int drawableId) {
    String imageUri = ContentResolver.SCHEME_ANDROID_RESOURCE +
            "://" + context.getResources().getResourcePackageName(drawableId)
            + '/' + context.getResources().getResourceTypeName(drawableId)
            + '/' + context.getResources().getResourceEntryName(drawableId);
    return imageUri;
}
 
Example 3
Source File: FatBeaconHelloWorld.java    From physical-web with Apache License 2.0 5 votes vote down vote up
@Override
public void startDemo() {
  Intent intent = new Intent(mContext, FatBeaconBroadcastService.class);
  intent.putExtra(FatBeaconBroadcastService.TITLE_KEY, "Hello World");
  String uriString = ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
      mContext.getPackageName() + "/" + R.raw.fatbeacon_default_webpage;
  intent.putExtra(FatBeaconBroadcastService.URI_KEY, uriString);
  mContext.startService(intent);
  mIsDemoStarted = true;
}
 
Example 4
Source File: WifiDirectHelloWorld.java    From physical-web with Apache License 2.0 5 votes vote down vote up
@Override
public void startDemo() {
  Intent intent = new Intent(mContext, FileBroadcastService.class);
  String uriString = ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
      mContext.getPackageName() + "/" + R.raw.wifi_direct_default_webpage;
  intent.putExtra(FileBroadcastService.FILE_KEY, uriString);
  intent.putExtra(FileBroadcastService.MIME_TYPE_KEY, "text/html");
  intent.putExtra(FileBroadcastService.TITLE_KEY, "Hello World");
  mContext.startService(intent);
  mIsDemoStarted = true;
}
 
Example 5
Source File: JoH.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static String getResourceURI(int id) {
    return ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + xdrip.getAppContext().getPackageName() + "/" + id;
}
 
Example 6
Source File: JoH.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static String getResourceURI(int id) {
    return ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + xdrip.getAppContext().getPackageName() + "/" + id;
}
 
Example 7
Source File: JoH.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public static String getResourceURI(int id) {
    return ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + xdrip.getAppContext().getPackageName() + "/" + id;
}
 
Example 8
Source File: JoH.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public static String getResourceURI(int id) {
    return ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + xdrip.getAppContext().getPackageName() + "/" + id;
}
 
Example 9
Source File: MusicLibrary.java    From android-MediaBrowserService with Apache License 2.0 4 votes vote down vote up
private static String getAlbumArtUri(String albumArtResName) {
    return ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
            BuildConfig.APPLICATION_ID + "/drawable/" + albumArtResName;
}