private EditText et;
private Button bt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et = (EditText) findViewById(R.id.editText1);
bt = (Button) findViewById(R.id.button1);
bt.setOnClickListener(this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1 && resultCode == Activity.RESULT_OK) {
ArrayList
.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
if (str.size() > 0) {
et.setText(str.get(0));
}
}
}
@Override
public void onClick(View arg0) {
if (arg0.getId() == R.id.button1) {
System.out.println("--------------");
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "语音录入");
startActivityForResult(intent, 1);
}
}
}
说这个startActivityForResult(intent, 1);地方有错,实在找不出哪有错,求大神指教!!
权限也加了,但是就是报错。