0

mms メッセージの送受信を検出してコンテンツをキャプチャするアプリを作成しています。「content://mms-sms/conversations」に contentResolver を使用してこれを行っています。これがトリガーされると、会話を反復処理して最後の会話 (送信されたばかり) を見つけます。すべてのデバイスでカーソルを設定すると「content://mms-sms/conversations」が機能しなかったため、「content://mms-sms/conversations?simple=true」を使用しています。繰り返し、リスト内の最初の会話を見つけ (リストは日付の降順に並べられています)、_id を渡して contentResolver.query(uri, Uri.Parse("content://mms/part") を使用して実際のコンテンツを取得します。 , selectionPart, null, null); ただし、このカーソルを使用して反復しようとすると、会話 ID のレコードが見つかりません。mmsがいつ送受信されたかを検出し、その情報を取得しようとしているだけです。これに関する多くのトピックを見てきましたが、問題を解決しているようには見えません。何か案は?ありがとう

public void getMMS(Context context)
{
    SentinelService.grabbingMMS = false;

    boolean sent, startup;
    final String[] projection = new String[] { "*" };

    Uri uri = Uri.parse("content://mms-sms/conversations?simple=true");
    Cursor cursor = contentResolver.query(uri, null, null, null, "_date DESC");

    if (cursor.moveToFirst()) {
    do 
    {
    String id = cursor.getString(cursor.getColumnIndex("_id"));
    String d = cursor.getString(cursor.getColumnIndex("date"));

        MMSLog mmsLog = buildMMSLog(id, sent);
    } while (cursor.moveToNext());
}



private MMSLog buildMMSLog(String mmsID, boolean sent)
{

String body = "", partID = "", imageString = null, type = "", tempType = "",       selectionPart = "mid=" + mmsID;
    Bitmap bitmap = null;
    Uri uri = Uri.parse(MMS_PART);
    Cursor cursor = contentResolver.query(uri, null, selectionPart, null,
            null);

    if (!cursor.isAfterLast()) {

        String[] s = cursor.getColumnNames();

        partID = cursor.getString(cursor.getColumnIndex("_id"));
        tempType = cursor.getString(cursor.getColumnIndex("ct"));

        if ("text/plain".equals(tempType)) {
            String data = cursor.getString(cursor.getColumnIndex("_data"));
            if (data != null) {
                body = getMMSText(partID);
            } else {
                body = cursor.getString(cursor.getColumnIndex("text"));
            }
        } else if ("image/jpg".equals(tempType)
                || "image/gif".equals(tempType)
                || "image/jpeg".equals(tempType)
                || "image/bmp".equals(tempType)
                || "image/png".equals(tempType)) {
            bitmap = getMMSImage(partID);
            type = tempType;
        }

    }

    try {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bitmap.compress(CompressFormat.JPEG, 50, stream);
        bitmap.recycle();
        byte[] byteArray = stream.toByteArray();
        stream = new ByteArrayOutputStream();
        imageString = new String(Base64.encodeBase64(byteArray));
    }

    catch (Exception ex) {
    }

    return new MMSLog(getAddressNumber(mmsID, sent), body, imageString,
            type, sent);
}
4

1 に答える 1