1

I am new to Android services so please excuse the "noobish" question. How could I bind a Service to any incoming SMS, calls, or email? Should I use the onBind method? Or should I use a BroadcastReciever?

Mohit Deshpande
  • 53,877
  • 76
  • 193
  • 251

1 Answers1

2

How could I bind a Service to any incoming SMS, calls, or email?

You don't.

Handling incoming SMSes technically is not supported by the Android SDK. There is a broadcast Intent that is sent out when an SMS comes in whose action, unfortunately, is undocumented. If you were to use this, you would need a manifest-registered BroadcastReceiver.

There is an ACTION_PHONE_STATE_CHANGED Intent that is broadcast whenever the phone is in use, but this includes incoming and outgoing calls. Once again you would need a manifest-registered BroadcastReceiver.

Either of those BroadcastReceiver objects could (and perhaps should) pass control to an IntentService via startService(), so the service can do the real work.

There is no concept of "email" in the Android OS. That is an application concept. At this point, there are probably more email applications for Android than you have bones in your body. Few, if any, have a documented and supported API, such as broadcast Intents, AFAIK.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Would you happen to know the intent filter's action that receives gmail or mail application? – Mohit Deshpande Feb 12 '11 at 15:48
  • @Mohit Deshpande: There are no "intent filter's action that receives gmail or mail application". – CommonsWare Feb 12 '11 at 16:06
  • Doesn't the gmail/mail application have to publish something to notify the Android OS of the email? – Mohit Deshpande Feb 12 '11 at 16:28
  • @Mohit Deshpande: There is no concept of "email" in the Android OS. That is an application concept. Outlook doesn't tell Windows "of the email". Thunderbird doesn't tell Windows or Linux "of the email". – CommonsWare Feb 12 '11 at 17:11