Search code examples
androidsmsandroid-contentprovidermessagingrich-communications-services

How to retrieve RCS messages from Android Devices


How do i retreive RCS messages in android. I can retreive SMS/MMS using contentproviders, is there any URI for RCS messaging availlable for android?

I found that my device has this contentprovider availlabe so I tried using this :

  Uri.parse("content://com.gsma.services.rcs.provider.chat/chatmessage")

but this gives me a Security Exception like This :

java.lang.SecurityException: Permission Denial: opening provider com.sec.internal.ims.servicemodules.tapi.service.provider.ChatProvider from ProcessRecord{31c3db7 9607:com.sol.testsms/u0a403} (pid=9607, uid=10403) requires com.gsma.services.permission.RCS or com.sec.imsservice.WRITE_IMS_PERMISSION

after adding the permissions stated in the error message I still get the error.

Can anyone help with this?


Solution

  • This is worked only in the device where google messaging is enabled :

    RCS message basically is stored in Uri.parse("content://mms") content providers.You can alternatively useTelephony.Mms.CONTENT_URI. You can read the RCS related message by passing the URI Uri.parse("content://mms") in the contentResolver. Actually mms content type read the both mms and RCS message. Sample code is given here.

     val cursor = contentResolver.query(
            Uri.parse("content://mms"),
            arrayOf("*"),
            "thread_id = ?",
            selectionArgs,
            null
        )