Android从标题获取短信号码

时间:2015-02-13 10:28:27

标签: android service sms broadcastreceiver

我正在尝试在短信收件箱中获取号码。我成功了,但我现在又遇到了另一个问题 一些公司使用他们的名字发送消息,如Ebay或Vodafone。当我尝试获取电话号码时,它只显示这样的公司名称。我真的需要得到他们的号码。感谢您的帮助:)

地址:沃达丰

人:null

日期:1231321

身体:....

  System.out.println("Mesaj Log Çıktıları");
            Uri uriSms = Uri.parse("content://sms/inbox");
            Cursor c = getApplicationContext().getContentResolver().query(uriSms,
                new String[] { "_id", "thread_id", "address",

                    "person", "date", "body" }, null, null, null);
            if (c != null && c.moveToFirst()) {
                do {
                    long id = c.getLong(0);
                    String threadid = c.getString(1);

                    String address = c.getString(2);
                    String person = c.getString(3);
                    String date = c.getString(4);
                    String body = c.getString(5);
                    System.out.println("******Mesaj "+id+"*******");
                    System.out.println("Thread id : "+threadid );
                    System.out.println("Gelen Adres : "+address);
                    System.out.println("Person : "+person);
                    System.out.println("Date : "+date);
                    System.out.println("Body : "+body);
                    if(address.equals("44434967")){
                        //a company phone number in inbox
                    }
                } while (c.moveToNext());
            }

0 个答案:

没有答案