Get unread information

Source: Internet
Author: User

Tag:android    sms     unread SMS    

Package Com.example.missedcall;import Android.content.context;import Android.database.cursor;import Android.net.uri;import Android.provider.calllog;import android.provider.calllog.calls;/** * Do not like to write blog, directly on the code,        Note The Content section refers to the material on the Web * * First post the relevant protocol: Content://sms/inbox Inbox Content://sms/sent sent Content://sms/draft Draft content://sms/outbox Outbox content://sms/failed send failed content://sms/queued to send list Outbox no query to data on simulator    , found on the simulator long time also did not find the Outbox, very depressed. The SMS related fields in the database are as follows: _id a self-increment field, starting from 1 thread_id serial number, same Sender ID same address sender mobile number person contact list number, MO Null Date Sender Date protocol protocol, divided into: 0 sms_rpoto, 1 mms_proto read whether reading 0 unread, 1 read status     State-1 Receive, 0 complete, pending, failed type all = 0;     INBOX = 1;     SENT = 2;     DRAFT = 3;     OUTBOX = 4;     FAILED = 5; QUEUED = 6; Body SMS Content service_center SMS Service center number subject SMS theme Reply_path_present TP-REPLY-path Locked * * * */public class Misscall {/** * Read missed phone number * */public static int Readmisscall (context context) {        int result = 0;            cursor cursor = context.getcontentresolver (). Query (CallLog.Calls.CONTENT_URI, new string[] {Calls.type }, "Type=?"        And new=? ", new string[] {calls.missed_type +" "," 1 "}," date desc ");            if (cursor! = NULL) {result = Cursor.getcount ();        Cursor.close ();    } return result;        }/** * Get unread MMS number * */public static int Getnewmmscount (context context) {int result = 0; Cursor CSR = Context.getcontentresolver (). Query (Uri.parse ("Content://mms/inbox"), NULL, "read = 0", NULL, n        ULL);            if (CSR! = null) {result = Csr.getcount ();        Csr.close ();    } return result;        }/** * Get unread SMS number * */public static int Getnewsmscount (context context) {int result = 0; Cursor CSR = context.getcOntentresolver (). Query (Uri.parse ("content://sms"), NULL, "type = 1 and read = 0", null, NULL);            if (CSR! = null) {result = Csr.getcount ();        Csr.close ();    } return result; }}

Get unread information

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.