android - Will the address field store multiple phone numbers when I send a sms to multiple phone numbers at one time? -


when send sms in android mobile phone, can select multiple contact (please see a.png ), , sms 1 record.

can sms query using "content://sms/" ? field "address" return multiple phone numbers?

thanks!

a.png

enter image description here

    public static list<string> listdeleteold(context mycontext, smsrange msmsrange, int beforedays ) {         list<string> mlistsmsid=new arraylist<string>();          uri uri=publicparfun.geturibysmsrange(msmsrange);          date beforedate=getcurrentbefore(beforedays);         string[] projection = new string[] {"_id","address"};         cursor cur = mycontext.getcontentresolver().query(uri, projection, "date<=" + beforedate.gettime(), null,  "date desc");           while(cur.movetonext()){                        string s=cur.getstring(cur.getcolumnindex("address"));                    }         cur.close();          return mlistsmsid;     }     public static uri geturibysmsrange(smsrange msmsrange){         uri uri=null;          final string sms_uri_all = "content://sms/";         final string sms_uri_inbox = "content://sms/inbox";         final string sms_uri_send = "content://sms/sent";         final string sms_uri_outbox = "content://sms/outbox";         final string sms_uri_draft = "content://sms/draft";          switch (msmsrange){             case all:                 uri = uri.parse(sms_uri_all);                 break;              case inbox:                 uri = uri.parse(sms_uri_inbox);                 break;              case sentbox:                 uri = uri.parse(sms_uri_send);                 break;              case outbox:                 uri = uri.parse(sms_uri_outbox);                 break;              case draft:                 uri = uri.parse(sms_uri_draft);                 break;         }          return uri;     } 

set variables example:

private static final uri sms_sent_uri = uri.parse("content://sms/sent"); private static final string sms_order = "date desc"; private static final string address_column_name = "address"; private static final string date_column_name = "date"; private static final string body_column_name = "body"; private static final string type_column_name = "type"; private static final string id_column_name = "_id"; private static final string sms_preferences = "sms_preferences"; 

you have crete smsobject. loop trough cursor.

the whole code: (call checknewoutgoingsms(context))

 private void checknewoutgoingsms(context context) {      cursor smscursor = getsmscursor(context);     list<sms> smslist = getlastsmslist(smscursor,context);     if (smslist != null && smslist.size() > 0) {         protectorwsodao mwtprotectordao = new protectorwsodao();         (sms sms : smslist) {             //             //             //read sms content             //             //         }         manager.getinstance(context).senddatatoserver(mwtprotectordao);     }     smscursor.close(); }  public static cursor getsmscursor(context context) {     return context.getcontentresolver().query(sms_sent_uri, null, null, null, sms_order); }  private list<sms> getlastsmslist(cursor smscursor, context context) {     list<sms> smslist = new arraylist<sms>();     final int lastsmsintercepted = smsstorage.getlastsmsintercepted();     boolean update = false;      if (smscursor != null) {         if (smscursor.movetofirst()) {             {                 sms smsparsed = parsesms(smscursor, context);                 smslist.add(smsparsed);               } while (smscursor.movetonext());         }     }     return smslist; }  public static sms parsesms(cursor cursor, context context) {     string number = cursor.getstring(cursor.getcolumnindex(address_column_name));     string date = cursor.getstring(cursor.getcolumnindex(date_column_name));     string content = cursor.getstring(cursor.getcolumnindex(body_column_name));     int smsid = cursor.getint(cursor.getcolumnindex(id_column_name));      return new sms(sms.send, smsid, number, date, content); } 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -