识别器Intent在豆形软糖和棒棒糖上的表现不同

时间:2016-08-16 16:12:24

标签: java android speech-recognition android-4.2-jelly-bean

这是我的代码。

speakButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
                intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                        RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
                intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Voice recognition");
                startActivityForResult(intent, REQUEST_CODE);
            }
        });

        PackageManager pm = getPackageManager();
        List<ResolveInfo> activities = pm.queryIntentActivities(
                new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),0);
        if(activities.size() == 0){
            speakButton.setEnabled(false);
            speakButton.setText("Recognizer not present");
        }

它在不同设备上的运行方式不同。它在棒棒糖上工作正常,但在豆荚上显示“识别器不存在”。

谢谢

0 个答案:

没有答案