예제 #1
0
  public static PduPart constructPartFromUri(Context context, Uri uri)
      throws IOException, MediaTooLargeException {
    PduPart part = new PduPart();

    assertMediaSize(context, uri, MmsMediaConstraints.MAX_MESSAGE_SIZE);

    Cursor cursor = null;

    try {
      cursor =
          context
              .getContentResolver()
              .query(uri, new String[] {Audio.Media.MIME_TYPE}, null, null, null);

      if (cursor != null && cursor.moveToFirst())
        part.setContentType(cursor.getString(0).getBytes());
      else throw new IOException("Unable to query content type.");
    } finally {
      if (cursor != null) cursor.close();
    }

    part.setDataUri(uri);
    part.setContentId((System.currentTimeMillis() + "").getBytes());
    part.setName(("Audio" + System.currentTimeMillis()).getBytes());

    return part;
  }
예제 #2
0
  private static PduPart constructPartFromUri(Context context, Uri uri)
      throws IOException, MediaTooLargeException {
    PduPart part = new PduPart();
    ContentResolver resolver = context.getContentResolver();
    Cursor cursor = null;

    try {
      cursor =
          resolver.query(uri, new String[] {MediaStore.Video.Media.MIME_TYPE}, null, null, null);
      if (cursor != null && cursor.moveToFirst()) {
        Log.w("VideoSlide", "Setting mime type: " + cursor.getString(0));
        part.setContentType(cursor.getString(0).getBytes());
      }
    } finally {
      if (cursor != null) cursor.close();
    }

    if (getMediaSize(context, uri) > MAX_MESSAGE_SIZE)
      throw new MediaTooLargeException("Video exceeds maximum message size.");

    part.setDataUri(uri);
    part.setContentId((System.currentTimeMillis() + "").getBytes());
    part.setName(("Video" + System.currentTimeMillis()).getBytes());

    return part;
  }
예제 #3
0
  private PduPart getPart(Cursor cursor) {
    PduPart part = new PduPart();

    getPartValues(part, cursor);

    part.setDataUri(PartAuthority.getPartUri(part.getPartId()));

    return part;
  }
예제 #4
0
  private static PduPart constructPartFromUri(Uri uri) throws IOException, BitmapDecodingException {
    PduPart part = new PduPart();

    part.setDataUri(uri);
    part.setContentType(ContentType.IMAGE_JPEG.getBytes());
    part.setContentId((System.currentTimeMillis() + "").getBytes());
    part.setName(("Image" + System.currentTimeMillis()).getBytes());

    return part;
  }