Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.25 KB | None | 0 0
  1. private String getPartOfMMS(int mmsID) {
  2.         String selectionPart = "mid=" + mmsID;
  3.         Uri uri = Uri.parse("content://mms/part");
  4.         Cursor cursor = context.getContentResolver().query(uri, null,
  5.                 selectionPart, null, null);
  6.         try {
  7.             if (cursor.moveToFirst()) {
  8.                 do {
  9.                     String path = cursor.getString(cursor.getColumnIndex(Telephony.Mms.Part._DATA));
  10.                     if (path != null) {
  11.                         return path;
  12.                     }
  13.                 } while (cursor.moveToNext());
  14.             }
  15.             return null;
  16.         } finally {
  17.             cursor.close();
  18.         }
  19.  
  20.     }
  21.  
  22.  
  23.     private String getMmsText(int id) {
  24.         String selectionPart = "mid=" + id;
  25.         Uri uri = Uri.parse("content://mms/part");
  26.         Cursor cursor = context.getContentResolver().query(uri, null,
  27.                 selectionPart, null, null);
  28.         try {
  29.             if (cursor.moveToFirst()) {
  30.                 do {
  31.                     String type = cursor.getString(cursor.getColumnIndex(Telephony.Mms.Part.CONTENT_TYPE));
  32.                     if ("text/plain".equals(type)) {
  33.                         String path = cursor.getString(cursor.getColumnIndex(Telephony.Mms.Part.TEXT));
  34.                         if (path != null) {
  35.                             return path;
  36.                         }
  37.                     }
  38.                 } while (cursor.moveToNext());
  39.             }
  40.         } finally {
  41.             cursor.close();
  42.         }
  43.         return null;
  44.     }
  45.  
  46.     private String getMmsType(int id) {
  47.         String selectionPart = "mid=" + id;
  48.         Uri uri = Uri.parse("content://mms/part");
  49.         Cursor cursor = context.getContentResolver().query(uri, null,
  50.                 selectionPart, null, null);
  51.         try {
  52.             if (cursor.moveToFirst()) {
  53.                 do {
  54.                     String type = cursor.getString(cursor.getColumnIndex(Telephony.Mms.Part.CONTENT_TYPE));
  55.                     if (!type.equals("application/smil")) {
  56.                         return type;
  57.                     }
  58.                 } while (cursor.moveToNext());
  59.             }
  60.         } finally {
  61.             cursor.close();
  62.         }
  63.         return null;
  64.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement