Friday, March 11, 2011

Android SMS Send and Receive.

Android SMS Send And Receive Application.


you can check this sms send receive local emulator.

just create two emulator .

where you give  phone no that place you have pass that receiving emulator no:5556

first emulator no:5554(sms sent)

second emulator no:5556(receive sms) .

source code
serbt.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // TODO Auto-generated method stub
                EditText no=(EditText)findViewById(;
                EditText name=(EditText)findViewById(;
                EditText author=(EditText)findViewById(;
                EditText version=(EditText)findViewById(;
                data.insertData(no.getText().toString(), name.getText().toString(), author.getText().toString(), version.getText().toString());
                String phoneNo = "5556";
                String message = "Books Succesfully  Details Added!!!!"+","+no.getText().toString()+","+name.getText().toString()+","+author.getText().toString()+","+version.getText().toString();                
                if (phoneNo.length()>0 && message.length()>0)               
                    sendSMS(phoneNo, message);               
                        "Please enter both phone number and message.",
                Intent in=new Intent(AddBooksActivity.this,AddBooksActivity.class);
                // ArrayList<String> getData = data.getAllData();                          
        Screen Shot First Emulator:5554


Second Emulator 5556


Source Code:
for receving purpose

    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
         //---get the SMS message passed in---
        Bundle bundle = intent.getExtras();       
        SmsMessage[] msgs = null;
        String str = "";           
        if (bundle != null)
            //---retrieve the SMS message received---
            Object[] pdus = (Object[]) bundle.get("pdus");
            msgs = new SmsMessage[pdus.length];           
            for (int i=0; i<msgs.length; i++){
                msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);               
                str += "SMS from " + msgs[i].getOriginatingAddress();                    
                str += " :";
                str += msgs[i].getMessageBody().toString();
                str += "\n";       
            //---display the new SMS message---
            Toast.makeText(context, str, Toast.LENGTH_SHORT).show();

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...