confused with BroadcastReceiver
<p>i have the following pgm which responds with a Toast with an incoming msg and also speaks out the received msg, however there seems to be no speech synthesis in background but i still can see the Toast though, so should i start a service from the onReceive method (don't know if that's possible) here and then in the startService method  , write the speak method??</p>

<p>here's one of my pgms:</p>

<p><strong>Receiver</strong></p>

<pre><code>package com.example.TextSpeaker;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.telephony.SmsMessage;
import android.util.Log;
import android.widget.Toast;

public class Receiver extends BroadcastReceiver{


public static String str;
@Override
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();
    Log.d("Receiver","Message received successfully");

    SmsMessage[] msgs = null;

    if(bundle!=null)
    {
        // retrive the sms received

        Object[] pdus = (Object[])bundle.get("pdus");
        msgs = new SmsMessage[pdus.length];
        for(int i=0;i&lt;msgs.length;i++)
        {
            str="";
            msgs[i]=SmsMessage.createFromPdu((byte[]) pdus[i]);
            str+="Message From "+msgs[i].getOriginatingAddress()+".   ";
            str+="The message is "+msgs[i].getMessageBody().toString();
            //TextSpeaker.mtts.speak(Receiver.str, TextToSpeech.QUEUE_FLUSH,null);
            //str="";

        }
        Toast.makeText(context,str,Toast.LENGTH_LONG).show();
        TextSpeaker.mtts.speak(Receiver.str, TextToSpeech.QUEUE_FLUSH,null);

    }
}
</code></pre>

<p>}</p>
