Android accesses SMS inbox

Source: Internet
Author: User

Accessing the SMS inbox is another common requirement. First, you must grant the permission to read the SMS

 

Add to description file. After adding this permission, you can read short messages in the SMS inbox.

To read SMS messages, you must query the SMS inbox. The following is our code list.

Layout File

 



Our custom ListActivity

 



The above code opens the SMS inbox and creates a list. Each item in the list contains the body of the SMS message. Our layout file only contains a simple TextView, which contains the body of each message in the list. To obtain the message list, you can create a URI (content: // SMS/inbox) pointing to the sms inbox and perform a simple query. Then, filter the text of the SMS message and set the ListActivity list adapter. Execute the above Code to see the message in the inbox, as shown below.



Make sure that your inbox contains SMS messages.

Because you can access the SMS inbox, you can access other SMS-related folders, such as the sent folder or draft box folder. The only difference between accessing the inbox and accessing other folders lies in the specified URI. For example, you can query content: // sms/sent to access the sent folder. The following is a complete list of SMS folders and the URI of each folder.

All Folders: content: // sms/all
Inbox: content: // sms/inbox
Sent: content: // sms/sent
Draft: content: // sms/draft
Sender: content: // sms/outbox
Failed to send: content: // sms/failed
Queue message: content: // sms/queued
Not delivered: content: // sms/undelivered

Conversation: content: // sms/conversations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.