ActivityNotFoundException:找不到用于处理Intent的活动(RECOGNIZE_SPEECH) [英] ActivityNotFoundException: No Activity found to handle Intent (RECOGNIZE_SPEECH)

查看:56
本文介绍了ActivityNotFoundException:找不到用于处理Intent的活动(RECOGNIZE_SPEECH)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用语音识别器制作一个应用.这是我的一部分代码:

I'm trying to make an app using the voice recognizer. This is a piece of my code:

public class Habla extends Activity{

   private static int code = 123;
   ...
   public void escuchar()
   {
       Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
       intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel);

       intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, numberResults);
       startActivityForResult(intent, code);
    }
...
}

错误如下:

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

为什么会发生? .Habla是运行.MainActivity中的按钮运行的类,因此AndoridManifest为:

Why does it happen? .Habla is a class which is run pushing a button in .MainActivity, so the AndoridManifest is:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.emiliomorillanieto.practica3" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".Habla"
            android:parentActivityName=".MainActivity" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".MainActivity" />
        </activity>
   </application>
</manifest>

推荐答案

原因是语音搜索应用.您可以通过在设备上手动安装该问题来解决该问题.但是还有另一种方法.这将在如下所示的网络视图中打开应用程序的链接

The reason is voice search app from google is missing on the device you are using. You can solve the problem by manually installing it on your device. But there is another way to do so. That's opening the link of the app in a webview like following

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 your_browser_intent = new Intent(Intent.ACTION_VIEW,         

    Uri.parse("https://market.android.com/details?id=APP_PACKAGE_NAME"));
    startActivity(your_browser_intent);
}

您也可以通过编码而不使用webview来做到这一点,但这是很多工作,您需要编写一堆代码.因此,我认为使用网络视图几乎可以.

You can also do it by coding and not using webview but that's a lot of work and you need to write a whole bunch of code. So, I think using a webview is pretty much ok.

这篇关于ActivityNotFoundException:找不到用于处理Intent的活动(RECOGNIZE_SPEECH)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆