永发信息网

为什么我安卓语音识别报ActivityNotFoundException错误,求大神指导!

答案:2  悬赏:60  手机版
解决时间 2021-03-19 11:32
  • 提问者网友:姑娘长的好罪过
  • 2021-03-18 18:22
public class MainActivity extends Activity implements OnClickListener {

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 str = data
.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);地方有错,实在找不出哪有错,求大神指教!!
权限也加了,但是就是报错。
最佳答案
  • 五星知识达人网友:琴狂剑也妄
  • 2021-03-18 18:34
你这个是新打开了个activity,所以要在manifest.xml里注册声明才可以
全部回答
  • 1楼网友:十鸦
  • 2021-03-18 19:26
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯