a basic Text to speech app not working
<p>i tried the following on the emulator but the as the app starts it gives a runtime error . could someone please help me on this . Heres' the code i tried </p>

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

import java.util.Locale;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;

public class TextSpeaker extends Activity {
/** Called when the activity is first created. */
int MY_DATA_CHECK_CODE = 0;
private TextToSpeech mtts;
String test1="hello world";
String test2="hi i am working fine";
    @Override

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Intent myintent = new Intent();
    myintent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
    startActivityForResult(myintent, MY_DATA_CHECK_CODE);
}
    protected void onActivityResult(int requestcode,int resultcode,Intent data)
    {
        if(requestcode == MY_DATA_CHECK_CODE)
        {
            if(resultcode==TextToSpeech.Engine.CHECK_VOICE_DATA_PASS)
            {
                // success so create the TTS engine
                mtts = new TextToSpeech(this,(OnInitListener) this);
                mtts.setLanguage(Locale.ENGLISH);
                mtts.speak(test1, TextToSpeech.QUEUE_FLUSH, null);
                mtts.speak(test2, TextToSpeech.QUEUE_FLUSH, null);
            }
            else
            {
                //install the Engine
                Intent install = new Intent();
                install.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
                startActivity(install);
            }
        }

    }


}
</code></pre>
