【问题标题】:Search the Inbox content by given string按给定字符串搜索收件箱内容
【发布时间】:2012-07-08 16:56:26
【问题描述】:

我想开发一个应用程序,其中的一小部分将从我设备收件箱中的 EditText 中搜索消息字符串....

我已经提到了一些链接,例如

Search sms Inbox

https://stackoverflow.com/questions/8941228/how-to-read-all-sms-from-inbox-in-android-2-2-and-above

http://androidforums.com/android-applications/1773-how-read-sms-android.html

Read all SMS from a particular sender

但无法实现... 谁能帮我写一段有用的代码...在此先感谢。

【问题讨论】:

  • 答案参考我的评论...

标签: android search full-text-search sms


【解决方案1】:

我终于得到了答案,但不知道它是否是最有效的解决方案。如果有更有效的解决方案,请纠正我。

我首先检查了收件箱中的特定文本到我在搜索框中插入的文本。如果文本匹配,那么我将其插入到 ArrayList 中。最后我打印整个 ArrayList。

public ArrayList<String> check(String str)
{

    boolean fullContainsSub = str.toUpperCase().indexOf(content.toUpperCase()) != -1;
    //String styledText = "This is <font color='red'>simple</font>.";
    //item.setText(Html.fromHtml(styledText), ListView.BufferType.SPANNABLE);

    if(fullContainsSub)
    {
     itemList.add(str);
    }
    return itemList;
}

这里 str 是收件箱中的文本,而 content 将是搜索框文本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-03
    相关资源
    最近更新 更多