package [Link].
speechtotext;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity {
protected static final int RESULT_SPEECH = 1;
private ImageButton btnSpeak;
private TextView txtText;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
txtText = (TextView) findViewById([Link]);
btnSpeak = (ImageButton) findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(
RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
[Link](RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-
US");
try {
startActivityForResult(intent, RESULT_SPEECH);
[Link]("");
} catch (ActivityNotFoundException a) {
Toast t = [Link](getApplicationContext(),
"Opps! Your device doesn't support Speech
to Text",
Toast.LENGTH_SHORT);
[Link]();
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate([Link], menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in [Link].
int id = [Link]();
if (id == [Link].action_settings) {
return true;
}
return [Link](item);
}
}