Permalink
Browse files

<cj> Can receive and parse sms msgs

  • Loading branch information...
1 parent 4838971 commit 59ee5d296d390fe3a6f971dfd35c9dfe6a3b8839 @chandanjog committed Mar 13, 2012
Binary file not shown.
View
Binary file not shown.
View
@@ -1 +1 @@
-2012-03-12T20:36:48+05:30
+2012-03-12T21:23:31+05:30
View
@@ -1,5 +1,5 @@
#Last build type
-#Mon, 12 Mar 2012 20:36:48 +0530
+#Mon, 12 Mar 2012 21:23:31 +0530
build.last.target=debug
View
@@ -1,9 +1,30 @@
require 'ruboto/broadcast_receiver'
+import "android.util.Log"
+import "android.telephony.SmsMessage"
# will get called whenever the BroadcastReceiver receives an intent (whenever onReceive is called)
+
+identifier = "EZSMS"
+targetURL = "localhost:3000"
+
RubotoBroadcastReceiver.new_with_callbacks do
def on_receive(context, intent)
- Log.v "MYAPP", intent.getExtras.to_s
+ messages = get_messages_from_intent(intent)
+ messages.each do |sms|
+ Log.v "SMS_BODY", sms.get_display_message_body()
+ Log.v "SMS_SENDER", sms.get_display_originating_address()
+ end
+ #Log.v "MYAPP", intent.getExtras.to_s
end
+
+ def get_messages_from_intent(intent)
+ pdus = intent.get_extras.get("pdus")
+ messages = []
+ pdus.each do |item|
+ messages << SmsMessage.create_from_pdu(item)
+ end
+ messages
+ end
+
end

0 comments on commit 59ee5d2

Please sign in to comment.