3

Hey! I'd like to know which is the intent android sends when it sends a message. And how can I listen for this intent in my application. I wanted that, when I send a message in native android messaging, my application listen this intent, so it will know a new message has been sent.

So, which one is it, and how to listen for this intent?

Thanks.

rogcg
  • 10,451
  • 20
  • 91
  • 133

2 Answers2

2

I believe the Intent is:

public static final String SMS_RECEIVED_ACTION = "android.provider.Telephony.SMS_SENT";

This guy had an article about how to build a BroadcastReceiver to do this.

http://mobiforge.com/developing/story/sms-messaging-android

However, I did a quick search through the Android documentation and couldn't find an android.provider.Telephony class. It may no longer be supported in the latest version of Android. However, its worth trying out. If you could respond back with a comment to let me know if this intent still works or not that'd be awesome. Not sure why it's not on the documentation site.

Here's a similar question about listening for sms received events:

android.provider.Telephony.SMS_RECEIVED not available

Community
  • 1
  • 1
plainjimbo
  • 7,070
  • 9
  • 41
  • 55
  • I'm gonna try, but in the link you parsed http://mobiforge.com/developing/story/sms-messaging-android tha guy sends a message from his own messaging application, and I use the native messaging application, so, he created his app, and he sends the Intent he wants, now, in native messaging app, we don't know what it sends, or if it sends. =/ But I'm gonna try this solution, and I'll respond back. Thanks. – rogcg Nov 07 '10 at 12:48
2

I'd like to know which is the intent android sends when it sends a message.

AFAIK, there is no Intent that is broadcast when Android sends an SMS. This is probably for privacy reasons as much as anything else.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 1
    I don't think its for privacy reasons, it makes no sense. I think the best alternative seems to be polling content://sms/sent, potentially using a ContentObserver. I don't know, what do you think about it? – rogcg Nov 07 '10 at 12:44
  • @psychlo: None of what you are proposing to do is supported by the Android SDK. There is no SMS content provider in the Android OS. For some devices that ship with the AOSP Messaging *application*, there is a content provider, but Google has told you not to use it (http://android-developers.blogspot.com/2010/05/be-careful-with-content-providers.html), and it may not exist on all devices. – CommonsWare Nov 07 '10 at 12:57
  • So, there is no solution for this problem? What is your sugestion? – rogcg Nov 08 '10 at 11:52
  • @psyhclo: My suggestion is that you focus on other capabilities for your application. – CommonsWare Nov 08 '10 at 12:14
  • @CommonsWare: you sayI should forget about this function? Not implement this kinf of function? Just forget about it? – rogcg Nov 08 '10 at 17:17
  • @psyhclo: As I wrote, my suggestion is that you focus on other capabilities for your application. – CommonsWare Nov 08 '10 at 19:16