按给定字符串搜索收件箱内容

时间:2012-07-09 09:45:08

标签: android search full-text-search sms

我想开发一个应用程序,其中一小部分将从我设备的收件箱中的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

但无法实现...... 任何人都可以帮助我使用一段有用的代码...在此先感谢。

1 个答案:

答案 0 :(得分: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 是收件箱中的文字,而 内容 将是搜索框文字。