1.public class SMSReceiver extends BroadcastReceiver {
2. /** TAG used for Debug-Logging */
3. protected static final String LOG_TAG = "SMSReceiver";
 
01. /** The Action fired by the Android-System when a SMS was received.
02. * We are using the Default Package-Visibility */
03. private static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";
04.
05. // @Override
06. public void onReceive(Context context, Intent intent) {
07.
08. Log.i(LOG_TAG, "[inside onReceive] ");
09.
10. if (intent.getAction().equals(ACTION)) {
11.
12. StringBuilder sb = new StringBuilder();
13. Bundle bundle = intent.getExtras();
14.
15. if (bundle != null) {
16. Object[] pdusObj = (Object[]) bundle.get("pdus");
17. SmsMessage[] messages = new SmsMessage[pdusObj.length];
18. for (int i = 0; i<pdusObj.length; i++) {
19. messages[i] = SmsMessage.createFromPdu ((byte[]) pdusObj[i]);
20.
21. Log.i("aaaaaaa", messages[i].getOriginatingAddress()
22. + "::" + messages[i].getMessageBody());
23. }
24.
25. Log.i(LOG_TAG, "[SMSApp Bundle] " + bundle.toString());
26.
27.
28. String m = messages.toString();
29.
30. if(m.equals("Where are you?"))
31. {
32. Toast.makeText(context, "맞았음+_+", Toast.LENGTH_SHORT).show();
33. }
34. else
35. {
36. Toast.makeText(context, "틀렸음ㅠ_ㅠ", Toast.LENGTH_SHORT).show();
37. }
38.
39.
40. // Consume this intent, that no other application will notice it.
41. this.abortBroadcast();
42.
43. // Start the Main-Activity
44. Intent i = new Intent(context, SMSActivity.class);
45. // i.setLaunchFlags(Intent.NEW_TASK_LAUNCH);
46. i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
47. context.startActivity(i);
48.
49. }
50. }
51.}
52.}


어떤분 블로그에서 수신된 문자를 가져와서 토스트로 보여주는 소스를 발견했는데요
거기다가 제가 그 받은 문자랑 제가 지정해놓은 문자랑 비교해서
맞으면 맞다고 토스트를 띄워주려고 하는데
자꾸 "틀렸음ㅠ_ㅠ" 이렇게만 나옵니다....

아무래도 String m 에 메세지가 들어가지 않는거 같은데
자바 초보라서 어떻게 값을 받아와야 할지 잘 모르겠어요.. 도와주세요ㅠ.ㅠ