Android SDK中 - ActivityNotFoundException [英] Android SDK - ActivityNotFoundException

查看:156
本文介绍了Android SDK中 - ActivityNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过Android开发者的食谱我的路。我在他们的榜样code进入,并正确编译。不过,我得到这个例外在运行时。

I am working my way through the Android Developer's Cookbook. I have entered in their example code, and it compiles correctly. However, I am getting this exception at run time.

下面是书中的code:

Here is the code from the book:

public class RecognizerIntentExample extends Activity {
    private static final int RECOGNIZER_EXAMPLE = 1001;
    private TextView tv;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        tv = (TextView) findViewById(R.id.text_result);

        //set up button listener 
        Button startButton = (Button)findViewById(R.id.trigger);
        startButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                //RecoginizerIntent prompts for speech and returns text
                Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
                intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
                intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say a word or phrase\nand it will show as text");
                startActivityForResult(intent, RECOGNIZER_EXAMPLE);
            }
        });
    }

    @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        //use a switch statement for more than one request code check
        if (requestCode == RECOGNIZER_EXAMPLE && resultCode==RESULT_OK) {
            //returned data is a list of matches to the speech input
            ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

            //display on screen
            tv.setText(result.toString());
        }

        super.onActivityResult(requestCode, resultCode, data);
    }
}

唯一的例外是从呼叫来 startActivityForResult(); 有谁知道什么可能导致这种

The exception is coming from the call to startActivityForResult(); Does anyone know what might be causing this?

推荐答案

听起来就像在设备或模拟器您正在测试上没有一个方法来解决这一意图。这里是在使用语音识别和确定信息,如果它是一个设备

Sounds like the device or emulator you are testing on doesn't have a way to resolve that intent. Here is information on using speech recognition and determining if it is availble on a device.

这篇关于Android SDK中 - ActivityNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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