コード例 #1
0
  private void getMmsContentType() {
    String selectionPart = "mid=" + mmsId;
    cursorMmsContent = getContentResolver().query(mmsPartUri, null, selectionPart, null, null);
    mmsBody = null;
    mmsImage = null;
    while (cursorMmsContent.moveToNext()) {
      String partId = cursorMmsContent.getString(cursorMmsContent.getColumnIndex("_id"));
      String type = cursorMmsContent.getString(cursorMmsContent.getColumnIndex("ct"));
      if ("text/plain".equals(type)) {
        String data = cursorMmsContent.getString(cursorMmsContent.getColumnIndex("_data"));
        if (data != null) {
          mmsBody = getMmsText(partId);
        } else {
          mmsBody = cursorMmsContent.getString(cursorMmsContent.getColumnIndex("text"));
        }
      }
      if ("image/jpeg".equals(type)
          || "image/bmp".equals(type)
          || "image/gif".equals(type)
          || "image/jpg".equals(type)
          || "image/png".equals(type)) {
        Bitmap bitmap = getMmsImage(partId);
        bitmap = Bitmap.createBitmap(bitmap);
        mmsImage = Converters.getBytes(bitmap);
        byte[] bytes = mmsImage;
      }
    }

    cursorMmsContent.close();
    getMmsExtras();
    mmsNumber = getAddressNumber(getApplicationContext(), mmsId);
    if (mmsNumber.contains("insert")) {
      mmsNumber = "sent";
      mmsName = null;
    } else {
      mmsNumber = Converters.stripNumberFormatiing(mmsNumber);
      if (mmsNumber.startsWith("1")) {
        mmsNumber = mmsNumber.substring(1);
        mmsName = findContactName(mmsNumber);
      } else if (mmsNumber.startsWith("+")) {
        mmsNumber = mmsNumber.substring(2);
        mmsName = findContactName(mmsNumber);
      } else {
        mmsNumber = Converters.stripNumberFormatiing(mmsNumber);
        mmsName = findContactName(mmsNumber);
      }
    }
  }
コード例 #2
0
  private void getSms() {

    int ID = cursorSms.getInt(cursorSms.getColumnIndex("_id"));

    if (ID != 0) {

      smsID = ID;
      smsLQID = i;

    } else {

      smsID = 0;
    }

    String number = cursorSms.getString(cursorSms.getColumnIndex("address"));

    if (number != null) {
      smsNumber = number;
      smsName = findContactName(number);
    } else {

      smsNumber = null;
    }

    int threadID = cursorSms.getInt(cursorSms.getColumnIndex("thread_id"));

    if (threadID != 0) {

      smsThreadId = threadID;
    } else {

      smsThreadId = 0;
    }

    String dateSent = cursorSms.getString(cursorSms.getColumnIndex("date_sent"));

    if (dateSent != null) {

      smsDateSent = dateSent;
    } else {

      smsDateSent = null;
    }

    int smsRead = cursorSms.getInt(cursorSms.getColumnIndex("read"));

    if (smsRead != 0) {

      smsHasRead = smsRead;
    } else {

      smsHasRead = 0;
    }

    int type = cursorSms.getInt(cursorSms.getColumnIndex("type"));

    if (type > 0) {

      smsType = type;
    } else {

      smsType = 0;
    }

    Long date = cursorSms.getLong(cursorSms.getColumnIndex("date"));

    if (date != null) {

      long thisdate = date;
      smsDate = Converters.getDate(thisdate, "EEE MMM dd HH:mm:ss zzz yyyy");
    } else {

      smsDate = null;
    }

    String message = cursorSms.getString(cursorSms.getColumnIndex("body"));

    if (message != null) {

      smsMessage = message;
    } else {

      smsMessage = null;
    }
  }