0

How I can get no sent messages?

Where I get all messages from Telephony.Sms.CONTENT_URI, it is good working. But if my message no sent (no many, no radio, etc), I no got in Telephony.Sms.CONTENT_URI.

Interesting moment: I sending the message from my app, with SmsManager. But default app can see no sent messages. And I can resend it.

UPD

fun getAllSms(context: Context): MutableList<SmsDto> {
    val reqCols = arrayOf(
        Telephony.Sms._ID, Telephony.Sms.ADDRESS, Telephony.Sms.BODY,
        Telephony.Sms.DATE,
        Telephony.Sms.DATE_SENT,
        Telephony.Sms.TYPE,
        Telephony.Sms.THREAD_ID,
        Telephony.Sms.STATUS,
        Telephony.Sms.READ,
        Telephony.Sms.SEEN,
    )
    val cr: ContentResolver = context.contentResolver
    val c: Cursor? = cr.query(Telephony.Sms.CONTENT_URI, reqCols, null, null, null)

    val messages = mutableListOf<SmsDto>()

    c?.let {
        if (c.count > 0) {
            while (c.moveToNext()) {
                messages.add(SmsDto[c])
            }
        }
    }

    c?.close()
    messages.sortByDescending { it.timestampInMillis }
    return messages
}

private fun load(cursor: Cursor) {
    cursor.getColumnIndex(Sms._ID).overMinusOneOrNull()?.let {
        rowId = cursor.getLong(it)
    }
    cursor.getColumnIndex(Sms.ADDRESS).overMinusOneOrNull()?.let {
        phone = cursor.getString(it)
    }
    cursor.getColumnIndex(Sms.BODY).overMinusOneOrNull()?.let {
        body = cursor.getString(it)
    }
    cursor.getColumnIndex(Sms.DATE).overMinusOneOrNull()?.let {
        timestampInMillis = cursor.getLong(it)
    }
    // Before ICS, there is no "date_sent" so use copy of "date" value
    cursor.getColumnIndex(Sms.DATE_SENT).overMinusOneOrNull()?.let {
        timestampSentInMillis = cursor.getLong(it)
    }
    cursor.getColumnIndex(Sms.TYPE).overMinusOneOrNull()?.let {
        type = SmsType.values()[cursor.getInt(it)]
    }
    cursor.getColumnIndex(Sms.THREAD_ID).overMinusOneOrNull()?.let {
        threadId = cursor.getLong(it)
    }
    cursor.getColumnIndex(Sms.STATUS).overMinusOneOrNull()?.let {
        status = SmsStatus.values().find { i ->
            i.rawStatus == cursor.getInt(it)
        } ?: SmsStatus.NONE
    }
    cursor.getColumnIndex(Sms.READ).overMinusOneOrNull()?.let {
        read = cursor.getInt(it) != 0
    }
    cursor.getColumnIndex(Sms.SEEN).overMinusOneOrNull()?.let {
        seen = cursor.getInt(it) != 0
    }
    uri = ContentUris.withAppendedId(Sms.CONTENT_URI, rowId).toString()
}

UPD2

enter image description here enter image description here enter image description here

How you can see, on the first image default app got a message from database. But I send it from my app. In the second image, we can see my app can't get from database no sent message.

The third image is information, for the show: my app getting inbox/outbox messages from the database.

Red text in default app: No sent. Touch pls for sending.

Valeriy
  • 191
  • 2
  • 10
  • I can't understand your question. – Raptor Jun 28 '22 at 08:05
  • I don't understand either. May I suggest you show us your code? That might help. – GabeRAMturn Jun 28 '22 at 08:08
  • I'm not sure if I understand the details correctly, but I will mention that non-default apps can only see _sent_ and _inbox_ messages since Marshmallow. They cannot see ones that are _failed_, _queued_, etc. Also, I'm not sure that there's any requirement for the system to save failed sends for non-defaults, but if it does, you'd have to be the default app to be able to do anything with the failed ones anyway. – Mike M. Jun 28 '22 at 13:26
  • @MikeM., Okay, thanks. Where I can get failed sms? I can't get it from Telephony.Sms.CONTENT_URI. – Valeriy Jun 28 '22 at 15:32
  • Only the default SMS app can get those. – Mike M. Jun 28 '22 at 15:34
  • Ohh, thanks. It's not very good ( – Valeriy Jun 28 '22 at 16:37

0 Answers0