Search the Inbox content by given string

不打扰是莪最后的温柔 提交于 2019-12-11 07:26:34

问题


I want to develop an application, the small part of which will search the string of message from an EditText in the Inbox of my device....

I have referred some links like

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

but could not make it possible... can anyone plz help me with a useful piece of code...Thanks in Advance.


回答1:


I finally got the answer but dont know if its the most efficient solution. Kindly correct me if there is some more efficient solution.

I first checked a particular text from Inbox to the text I inserted in Search Box. And if the text matches then I inserted it into the ArrayList. Finally I print whole 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;
}

Here str is text from Inbox while content will be search box text.



来源:https://stackoverflow.com/questions/11392584/search-the-inbox-content-by-given-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!