Hi guys, I am new to android coding and today tried to finish my first app.
But whenever i start this app it crashes after about 5 seconds. I am quite desperate because I couldnt find the error/ mistake yet. Has anybody an idea what I did wrong?
But whenever i start this app it crashes after about 5 seconds. I am quite desperate because I couldnt find the error/ mistake yet. Has anybody an idea what I did wrong?
Code:
package de.example.adorassprachausgabe;
import java.util.Locale;
import android.os.Bundle;
import android.app.Activity;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.view.View;
public class Sprachausgabe extends Activity implements OnInitListener{
private TextToSpeech tts;
/**Called when the activity is first created. */
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tts = new TextToSpeech(this,this);
}
public void onInit(int arg0) {
tts.setLanguage(Locale.GERMAN);
Button sprich = (Button) findViewById(R.id.button1);
sprich.setOnClickListener((OnClickListener) this);
}
public void onClick(View V){
EditText et = (EditText) findViewById(R.id.editText1);
tts.speak(et.getText().toString(), TextToSpeech.QUEUE_FLUSH, null);
}
}