首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android SDK - ActivityNotFoundException

Android SDK - ActivityNotFoundException
EN

Stack Overflow用户
提问于 2011-05-04 02:52:37
回答 1查看 495关注 0票数 0

我正在阅读Android Developer's Cookbook。我输入了他们的示例代码,它可以正确编译。然而,我在运行时得到了这个异常。

下面是书中的代码:

代码语言:javascript
复制
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();的调用有人知道这可能是什么原因吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-05-04 03:05:26

听起来你正在测试的设备或仿真器没有办法解决这个问题。以下是有关using speech recognition and determining if it is availble on a device的信息。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5874226

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档