Android SDK中 - ActivityNotFoundException [英] 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?
推荐答案
听起来就像在设备或模拟器您正在测试上没有一个方法来解决这一意图。这里是在使用语音识别和确定信息,如果它是一个设备一个上availble的>。
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屋!