Receiving SMS Using BroadcastReceiver and Intent

The following sample program is describe how to Receive sms using broadcast receiver with Intent
Step 1
Create broadcast receiver class for receiving sms


import android.content.*;
import android.os.Bundle;
import android.telephony.*;
import android.util.Log;
import android.widget.Toast;

public class SimpleSmsReciever extends BroadcastReceiver {

private static final String TAG = "Message recieved";

public void onReceive(Context context, Intent intent) {
Bundle pudsBundle = intent.getExtras();
Object[] pdus = (Object[]) pudsBundle.get("pdus");
SmsMessage messages =SmsMessage.createFromPdu((byte[]) pdus[0]);
Log.i(TAG, messages.getMessageBody());
Toast.makeText(context, "SMS Received : "+messages.getMessageBody(),


Step 2 :
Configure the AndroidManifest.xml file

<?xml version="1.0" encoding="utf-8"?>
<manifest android=""
package="" versioncode="1" versionname="1.0">
<application icon="@drawable/icon" label="@string/app_name">
<receiver name=".SimpleSmsReciever">
<action name="android.provider.Telephony.SMS_RECEIVED">
<uses-sdk minsdkversion="6">
<uses-permission name="android.permission.INTERNET">


  1. Hi,

    Let's say I have an activity wich should draw something depending on the received message....

    vDraw is my view to draw in (
    SMSDraw is my main activity (
    the drawing part is working...
    Now how can I get the information from the sms in my SMSdraw ????

  2. wether we have to register the recever ? in above exaample

  3. Is it worked on emulator> i m trying on emulator but not not getting toast nor printing log...

  4. It works but y to add internet permission???

  5. require "android.permission.RECEIVE_SMS" Permission in manifest file to work.

  6. i can't get the code running it always force closes when i run the application.what could be the reason.I've tried getting it to work but still unsuccessful

  7. This comment has been removed by the author.

  8. after receives sms, protect on the native inbox(doesn't go on inbox) Pls help me... pls tell the Code... My project pls

  9. This comment has been removed by the author.

  10. if i want to read sent messages by me at that time broadcast receiver doesn't working...

  11. thanks. it helps a lot. should include

  12. thanks.
    its easy and help a lot.
    i also refer some tutorial at

  13. Wow, you are a life saver man. Thanks for the awesome code :D Valentines Day 2014

  14. where is layout.xml file????????

  15. Well written and interesting thoughts. Its amazing how sometimes we get inspiration from the most unexpected of quarters !
    school app in chennai

  16. Hey, Really amazing..!
    I've bookmarked your post for reference and will love to follow you.
    Please keep it up good work for us.
    We provide a solution to use WhatsApp in your business communications and send invoices though tally.
    WhatsApp API Integration
    WhatsApp API Tally
    Tally Invoices to WhatsApp

  17. best induction cooktop. creates unique index on table/view. You cannot create unique index on duplicate columns and

  18. Thanks for provide great informatic and looking beautiful blog, really nice required information & the things i never imagined and i would request, wright more blog and blog post like that for us. Thanks you once agian afghani cap , antique gold choker necklace , embroidered crown patches , Afghani Hand Embroidered Shirt

  19. This is so fun! What a great content. Also I love how authentic you seem to be.