我的软件架构如下:
TabActivity是TabHost活动
它包含2个ActivityGroup:AGroup和BGroup
AGroup包含2个活动:A1Activity和A2Activity。
我想在A1Activity中实现识别器 我的代码如下:
private static final int VOICE_RECOGNIZER_REQUEST_CODE = 0x1008;
public void Recognizera() {
PackageManager pm = getPackageManager();
List<ResolveInfo> activities = pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
if(activities.size() != 0) {
try {
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, VOICE_RECOGNIZER_REQUEST_CODE);
}
catch(Exception e) {
e.printStackTrace();
}
}
}
@Override
protected void onActivityResult(int RequestCode, int ResultCode, Intent data) {
switch(RequestCode) {
case VOICE_RECOGNIZER_REQUEST_CODE:
if(RequestCode == VOICE_RECOGNIZER_REQUEST_CODE && ResultCode == RESULT_OK) {
ArrayList<String> results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
for(int i = 0; i < results.size(); i++) {
System.out.println("results " + results.get(i));
}
}
break;
}
super.onActivityResult(RequestCode, ResultCode, data);
}
但它显示“未知问题”,如下图所示
但是在logcat中没有任何错误消息
如何修改?