development
Revision | 3e6efddf287f59b1ccc4132107f3f586d32f0852 (tree) |
---|---|
Time | 2009-03-25 12:50:42 |
Author | Jeff Hamilton <> |
Commiter | The Android Open Source Project |
Automated import from //branches/master/...@141739,141739
@@ -16,17 +16,18 @@ | ||
16 | 16 | |
17 | 17 | package com.example.android.apis.app; |
18 | 18 | |
19 | +import com.example.android.apis.R; | |
20 | + | |
19 | 21 | import android.app.Activity; |
20 | 22 | import android.content.Intent; |
21 | 23 | import android.os.Bundle; |
24 | +import android.speech.RecognizerIntent; | |
22 | 25 | import android.view.View; |
23 | 26 | import android.view.View.OnClickListener; |
24 | 27 | import android.widget.ArrayAdapter; |
25 | 28 | import android.widget.Button; |
26 | 29 | import android.widget.ListView; |
27 | 30 | |
28 | -import com.example.android.apis.R; | |
29 | - | |
30 | 31 | import java.util.ArrayList; |
31 | 32 | |
32 | 33 | /** |
@@ -71,9 +72,10 @@ public class VoiceRecognition extends Activity implements OnClickListener { | ||
71 | 72 | */ |
72 | 73 | private void startVoiceRecognitionActivity() { |
73 | 74 | //TODO Get these values from constants |
74 | - Intent intent = new Intent("android.speech.action.RECOGNIZE_SPEECH"); | |
75 | - intent.putExtra("language_model", "free_form"); | |
76 | - intent.putExtra("prompt", "Speech recognition demo"); | |
75 | + Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); | |
76 | + intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, | |
77 | + RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); | |
78 | + intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speech recognition demo"); | |
77 | 79 | startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE); |
78 | 80 | } |
79 | 81 |
@@ -83,8 +85,8 @@ public class VoiceRecognition extends Activity implements OnClickListener { | ||
83 | 85 | @Override |
84 | 86 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
85 | 87 | if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) { |
86 | - //TODO get the value from a constant | |
87 | - ArrayList<String>matches = data.getStringArrayListExtra("results"); | |
88 | + ArrayList<String> matches = data.getStringArrayListExtra( | |
89 | + RecognizerIntent.EXTRA_RESULTS); | |
88 | 90 | mList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, |
89 | 91 | matches)); |
90 | 92 | } |