2012-12-29 2 views
0

전화 번호에 Android가 있는지 여부를 알 수있는 방법이 있습니까 ??전화 번호에 android에서 SMS 메시지가 있는지 확인

나는 sms 내용을 사용하여 말할 방법이 있는지 알고 싶다 porvider 나는 그것의 문서화하지 않으며 사용하는 recommanded를 알지 않으며 그러나 말할 것이다 방법 있는가 ??

나는 무엇을 시도했다.

이 문은 번호가 글로벌 코드 "001없이 저장 될 수 있기 때문에이

cursor = getContentResolver().query(
          Uri.parse("content://sms/inbox"), "address =?", new String[]{"001435436654747"}, null, 
          null); 

같은 where 절을 사용하지 못할

cursor = getContentResolver().query(
          Uri.parse("content://sms/inbox"), null, null, null, 
          null); 

모든받은 편지함 SMS (들)을 얻을 것이다 "등. 해결 방법이 있습니까?

답변

1

안녕하세요. 아래 코드를 사용하여 애플리케이션에서 자동으로 응답하는 수신 SMS를 수신합니다.

Uri myMessage = Uri.parse("content://sms/"); 
    ContentResolver cr = getContentResolver(); 
    Cursor c = cr.query(myMessage, new String[] { 
      "_id", "address", "date", "body", 
      "read" }, null, null, null); 

    System.out.println(Number); 

    while (c.moveToNext()) { 
     Number = c.getString(c.getColumnIndexOrThrow("address")).toString(); 

     if (Number.equals("001435436654747")) { 

      // DO YOUR STUFF 

     } 

    } 
관련 문제