2011-05-03 7 views
0

Android 개발자의 요리 책을 통해 진행 중입니다. 필자는 예제 코드를 입력 했으므로 올바르게 컴파일됩니다. 그러나 런타임에이 예외가 발생합니다.Android SDK - ActivityNotFoundException

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();에 대한 호출에서 오는 : 여기

이 책의 코드인가?

+3

귀하의 활동이 매니 페스트 파일에 언급되어 있습니까? – MByD

답변