No Activity found to handle Intent { act=android.speech.action.RECOGNIZE_SPEECH (has extras) }

前端 未结 2 1227
挽巷
挽巷 2020-12-19 04:59

The exception was thrown in the following code:

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_         


        
相关标签:
2条回答
  • 2020-12-19 05:06

    Vipin's solution works. I personally used this as my APP_PACKAGE_NAME: com.google.android.googlequicksearchbox

    So to recap the full solution you would do the following: (I modified it a little to first try the market:// scheme first and then fallback on the https:// if that fails.)

    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, "Speech recognition demo");
        startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);.
    } catch(ActivityNotFoundException e) {
        String appPackageName = "com.google.android.googlequicksearchbox";
        try {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
        } catch (android.content.ActivityNotFoundException anfe) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
        }
    }
    
    0 讨论(0)
  • 2020-12-19 05:16

    open link of the application(which you want to use) in web view

    as

    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, "Speech recognition demo");
    startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);.
    }
    catch(ActivityNotFoundException e)
    {
    Intent browserIntent = new Intent(Intent.ACTION_VIEW,   Uri.parse("https://market.android.com/details?id=APP_PACKAGE_NAME"));
    startActivity(browserIntent);
    
    }
    

    replace APP_PACKAGE_NAME in https://market.android.com/details?id=APP_PACKAGE_NAME with the voice rcognition applicatio package name on market

    0 讨论(0)
提交回复
热议问题