Skip to main content

Posts

Showing posts from July, 2013

Intercepting Sent and Received SMS in Android

Android API provides a very easy to way to get applications notified for phone related events such as SMS received and SMS sent. In this blog post we will learn how our app can receive these two notifications. Getting notified for Received SMS BroadcastReceiver  class allows applications to get notified for any android defined filter they want. All you have to do is to extend your class with BroadcastReceiver class and overrides its onReceive method. This method is called when Intent broadcast is received by this BroadcastReceiver. It has two parametes, first is a Context in which the receiver is running , second is the Intent which is being received. Its prototype in BroadcastReceiver class is like this public abstract void onReceive(Context context,Intent intent); So lets write our simple class whose onReceive method will be called on broadcast for any filter we are interested (in our case it is  android.provider.Telephony.SMS_RECEIVED  ). public class MyReceivedSmsRece