2

Here is my code.

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");
        }

Its running differently on different devices. Its working fine on lollipop but on jellybeans its showing "Recognizer not present".

Thank you

Shunan
  • 3,165
  • 6
  • 28
  • 48

0 Answers0