找不到处理Intent的活动{act = android.speech.action.RECOGNIZE_SPEECH(有附加内容)}

Bol*_*ton 6 android google-voice

以下代码抛出了异常:

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);.
Run Code Online (Sandbox Code Playgroud)

我用谷歌搜索,发现这是因为谷歌的语音搜索应用程序在我正在使用的设备上丢失.我可以通过手动安装应用程序来解决问题,但是我怎样才能在程序上安装apk,比如导入一些库或其他〜非常
感谢.

vip*_*pin 7

在Web视图中打开应用程序的链接(您要使用它)

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

}
Run Code Online (Sandbox Code Playgroud)

使用市场上的语音rcognition应用程序包名称替换https://market.android.com/details?id=APP_PACKAGE_NAME中的APP_PACKAGE_NAME

  • 伊戈尔没有谷歌语音搜索默认的东西但你可以使用谷歌的应用程序满足你的要求请尝试这个com.google.android.voicesearch (2认同)

Fra*_*rmu 6

Vipin 的解决方案有效。我个人将此用作我的 APP_PACKAGE_NAME: com.google.android.googlequicksearchbox

因此,要回顾完整的解决方案,您将执行以下操作:(我对其进行了一些修改,首先尝试该market://方案,然后在https://失败时回退。)

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)));
    }
}
Run Code Online (Sandbox Code Playgroud)