Android语音识别回调不工作
我正在尝试在我的应用程序中实现语音识别。它会很好地加载语音识别面板,识别你说的话,然后一旦完成,它就应该返回到调用onActivityResult方法的应用程序。不幸的是,它没有,只是返回到设备主屏幕。知道我做错了什么吗Android语音识别回调不工作,android,Android,我正在尝试在我的应用程序中实现语音识别。它会很好地加载语音识别面板,识别你说的话,然后一旦完成,它就应该返回到调用onActivityResult方法的应用程序。不幸的是,它没有,只是返回到设备主屏幕。知道我做错了什么吗 static final int VOICE_RECOGNITION_REQUEST_CODE = 1234; /** * Handler from the listening thread */ public Handler mhandle = new Handler(
static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;
/**
* Handler from the listening thread
*/
public Handler mhandle = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MAXOVER_MSG :
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
break;
default :
super.handleMessage(msg);
break;
}
}
};
/**
* Handle the results from the recognition activity.
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
Log.i("hmm","This never seems to get called..");
}
super.onActivityResult(requestCode, resultCode, data);
}
由于某种原因,您的应用程序可能正在
finish
ing。您是否使用单_TOP或单_TASK或其他特殊函数标志来启动活动(无论是出于启动活动的目的还是在AndroidManifest.xml中)