如何从 Android 中的彩信 URI 字符串中获取电话号码

问题描述

我正在使用 Kotlin 构建一个 Android 应用程序。在我的应用程序中,我需要从 URI 字符串中检索彩信的发件人地址/电话号码。我有一个格式为 content://mms/inBox/60 的 URI 字符串。

我尝试像这样使用 Id

private fun getSenderAddress(messageId: String): String {
        val selection = "_id = $messageId"
        val uri = Uri.parse("content://mms")
        val cursor: Cursor = context.contentResolver.query(uri,arrayOf("*"),selection,null,null) as Cursor
        val phone:String = cursor.getString(cursor.getColumnIndex("address"))
        return phone
    }

它不起作用。据说地址栏无效。如何从彩信 URI 字符串 content://mms/inBox/60 中获取发件人的电话号码?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)