SHARE
TWEET

Untitled

a guest May 22nd, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Override
  2. public void onReceive(Context context, Intent intent) {
  3.  
  4.     if (intent.getAction() != null) {
  5.         if (intent.getAction().equals(SMS_RECEIVED)) {
  6.             Bundle bundle = intent.getExtras();
  7.             if (bundle != null) {
  8.                 Object[] pdus = (Object[]) bundle.get("pdus");
  9.                 final SmsMessage[] messages = new SmsMessage[pdus.length];
  10.                 for (int i = 0; i < pdus.length; i++) {
  11.                     messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
  12.                     Log.e("Message Content : ", " == " + messages[i].getMessageBody());
  13.                     Log.e("Message Content Body : ", " == " + messages[i].getDisplayMessageBody());
  14.                     Log.e("Message recieved From", " == " + messages[0].getOriginatingAddress());
  15.                 }            
  16.             }
  17.         }
  18.     }
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top