How to Send text message by concatenating the two or more than two string variables like Number,Name,Date Through SMS in Android
<p>I made a service in android which receives a sms with specific keyword and automatically send the missed calls all info Number, Name, Date through sms at the same time. Now the problem is that when I send a single info like Number or Name or just Date it's fine but when i concatenate two or three variables in <code>sendTextMessage</code> method it's not working anymore well when i receive the sms which contains call log info it displays the different shapes in the place of Name, Number and Date. Can u tell me how can I do it I really need help.
My code is this :  </p>

<pre><code>package com.google.SmsReceive;

import java.text.SimpleDateFormat;

import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.telephony.gsm.SmsManager;
import android.telephony.gsm.SmsMessage;
import android.util.Log;
import android.widget.Toast;

@SuppressWarnings("deprecation")
public class SmsReceiveActivity extends BroadcastReceiver
{
    @Override
    public void onReceive(Context context, Intent intent) 
    {
        Uri Calllog=Uri.parse("content://call_log/calls");

        Cursor c=context.getContentResolver().query(Calllog, null, null, null, null);       

        if(c != null &amp;&amp; c.moveToFirst()) 
        {

            while (c.isAfterLast() == false) 
            {

        int _ID = c.getColumnIndex(android.provider.CallLog.Calls._ID);

        int _NUMBER = c.getColumnIndex(android.provider.CallLog.Calls.NUMBER);

        int _DATE = c.getColumnIndex(android.provider.CallLog.Calls.DATE);


        int _NAME = c.getColumnIndex(android.provider.CallLog.Calls.CACHED_NAME);

                String id = c.getString(_ID);

                String number = c.getString(_NUMBER);

                String date = c.getString(_DATE);

                String name = c.getString(_NAME);



                **String Msg="ID:"+id+"Name:"+name+"Number:"+number+"Time of Call is:"+date;**



                c.moveToNext();


                //---get the SMS message passed in---

                **Intent in = new Intent(context, SmsReceiveActivity.class);

                PendingIntent pi = PendingIntent.getBroadcast(context, 0, in, 0);**

                Bundle bundle = intent.getExtras();        

                SmsMessage[] msgs = null;

                String str = "";

                String body="";

                if (bundle != null)
                {

                    //---retrieve the SMS message received---
                    Object[] pdus = (Object[]) bundle.get("pdus");

                    msgs = new SmsMessage[pdus.length];            

                    for (int i=0; i&lt;msgs.length; i++)
                    {

                        msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);                

                        str += "SMS from " + msgs[i].getOriginatingAddress();                     

                        str += " :";

                        str += msgs[i].getMessageBody().toString();

                        str += "\n";

                        **body=msgs[i].getMessageBody();**

                        **String pass="B";**

                        **String no=msgs[i].getOriginatingAddress();**

                        **if(body.compareTo(pass)==0)**
                        {


                            SmsManager sm= SmsManager.getDefault();

                            **sm.sendTextMessage(no, null, Msg, pi, null);**    
                        }   
                    }
                }


        } 

    }


    }
}
</code></pre>
