SMS format and main fields of Android

Source: Internet
Author: User
ArticleDirectory
    • 3.1 Short Message
    • 3.2 sending and receiving
The SMS structure and main fields of Android are as follows:

Others Code
  1. _ Id // Short Message serial number
  2. Thread_id // The Conversation sequence number (conversation)
  3. Address // recipient
  4. Person // sender
  5. Date // Date
  6. Protocol // Protocol
  7. Read // read
  8. Status // status
  9. Type // type
  10. Reply_path_present //
  11. Subject // topic
  12. Body // Short Message Content
  13. Service_center // Service Center
 
_ Id // short message No. thread_id // conversation No. (conversation) address // recipient person // sender date // Date protocol // Protocol read // whether to read status // status type // type reply_path_present // subject // topic body/Short Message content service_center // Service Center
2. Get short messages from the machine.

See the code, which is relatively simple:

 

Java code
  1. SMS =NewArraylist <Map <string, Object> ();
  2. Cursor c = getcontentresolver (). Query (urisms,Null,Null,Null,
  3. Null);
  4. While(C. movetonext ()){
  5. Try{
  6. Item =NewHashmap <string, Object> ();
  7. // Read the contents of the SMS;
  8. For(IntI =0; I <C. getcolumncount (); I ++ ){
  9. String strcolumnname = C. getcolumnname (I );
  10. String strcolumnvalue = C. getstring (I );
  11. Item. Put (strcolumnname, strcolumnvalue );
  12. }
  13. }Catch(Exception e ){
  14. Log. W ("Exception :", E. getmessage ());
  15. }
  16. SMS. Add (item );
SMS = new arraylist <Map <string, Object> (); cursor c = getcontentresolver (). query (urisms, null); While (C. movetonext () {try {item = new hashmap <string, Object> (); // read the contents of the SMS; For (INT I = 0; I <C. getcolumncount (); I ++) {string strcolumnname = C. getcolumnname (I); string strcolumnvalue = C. getstring (I); item. put (strcolumnname, strcolumnvalue) ;}} catch (exception e) {log. W ("exception:", E. getmessage ();} SMS. add (item );
3. Conclusion 3.1 Short Message
 
In Android, there are many short message fields, but not every field is required.
3.2 sending and receiving
 
3.2.1 send Short Messages
 
It is relatively simple to send short messages, and there is a send method directly for the API. It should be noted that the length of Short Messages is controlled and the sending status is obtained.
 
3.2.2 receive short messages
 
The main idea is to register as a service and listen to system notifications when new messages are received, and then perform subsequent operations. There are a lot of online code and I will not discuss it much.

Related Article

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.