G2A Many GEOs
SHARE
TWEET

Untitled

code_hacker Oct 27th, 2011 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class SmsReceiver extends BroadcastReceiver
  2. {
  3.     @Override
  4.     public void onReceive(Context context, Intent intent)
  5.     {
  6.         //---get the SMS message passed in---
  7.         Bundle bundle = intent.getExtras();        
  8.         SmsMessage[] msgs = null;
  9.         String str = "";            
  10.         if (bundle != null)
  11.         {
  12.             //---retrieve the SMS message received---
  13.             Object[] pdus = (Object[]) bundle.get("pdus");
  14.             msgs = new SmsMessage[pdus.length];            
  15.             for (int i=0; i<msgs.length; i++){
  16.                 msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);                
  17.                 str += "SMS from " + msgs[i].getOriginatingAddress();                    
  18.                 str += " :";
  19.                 str += msgs[i].getMessageBody().toString();
  20.                 str += "\n";        
  21.             }
  22.             //---display the new SMS message---
  23.             Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
  24.         }                        
  25.     }
  26. }
  27.  
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
Top