Question

I,m trying to work through and test a Voice Recognition example based on the VoiceRecognition.java example at http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/VoiceRecognition.html

but when click on the button to create the activity, I get a dialog that says Connection problem. My Manifest file is using the Internet Permission, and I understand it passes the to the Google Servers. Do I need to do anything else to use this. Code below

UPDATE 2: Thanks to Steve, I have been able to install the USB Driver and debug the app directly on my Droid. Here is the LogCat output from clicking on my mic button:

03-08 18:36:45.686: INFO/ActivityManager(1017): Starting activity: Intent { act=android.speech.action.RECOGNIZE_SPEECH cmp=com.google.android.voicesearch/.IntentApiActivity (has extras) }

03-08 18:36:45.686: WARN/ActivityManager(1017): Activity is launching as a new task, so cancelling activity result.

03-08 18:36:45.787: DEBUG/NetworkLocationProvider(1017): setMinTime: 120000

03-08 18:36:45.889: INFO/ActivityManager(1017): Displayed activity com.google.android.voicesearch/.IntentApiActivity: 135 ms (total 135 ms)

03-08 18:36:45.905: DEBUG/NetworkLocationProvider(1017): onCellLocationChanged [802,0,0,4192,3]

03-08 18:36:45.951: INFO/MicrophoneInputStream(1429): Starting voice recognition with audio source VOICE_RECOGNITION

03-08 18:36:45.998: DEBUG/AudioHardwareMot(990): Codec sampling rate already 16000

03-08 18:36:46.092: INFO/RecognitionService(1429): ssfe url=http://www.google.com/m/voice-search

03-08 18:36:46.092: WARN/RecognitionService(1429): required parameter 'calling_package' is missing in IntentAPI request

03-08 18:36:46.115: DEBUG/AudioHardwareMot(990): Codec sampling rate already 16000

03-08 18:36:46.131: WARN/InputManagerService(1017): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@4487d240 (uid=10090 pid=3132)

03-08 18:36:46.131: WARN/IInputConnectionWrapper(3132): showStatusIcon on inactive InputConnection

03-08 18:36:46.248: WARN/MediaPlayer(1429): info/warning (1, 44)
03-08 18:36:46.334: DEBUG/dalvikvm(3206): GC freed 3682 objects / 369416 bytes in 293ms
03-08 18:36:46.358: WARN/MediaPlayer(1429): info/warning (1, 44)
03-08 18:36:46.412: WARN/MediaPlayer(1429): info/warning (1, 44)
03-08 18:36:46.444: WARN/MediaPlayer(1429): info/warning (1, 44)
03-08 18:36:46.475: WARN/MediaPlayer(1429): info/warning (1, 44)
03-08 18:36:46.506: WARN/MediaPlayer(1429): info/warning (1, 44)
03-08 18:36:46.514: INFO/MediaPlayer(1429): Info (1,44)
03-08 18:36:46.514: INFO/MediaPlayer(1429): Info (1,44)
03-08 18:36:46.514: INFO/MediaPlayer(1429): Info (1,44)
03-08 18:36:46.514: INFO/MediaPlayer(1429): Info (1,44)
03-08 18:36:46.514: INFO/MediaPlayer(1429): Info (1,44)
03-08 18:36:46.514: INFO/MediaPlayer(1429): Info (1,44)

The line that concerns me is the warning of the missing parameter calling-package.

UPDATE: Ok, I was able to replace my emulator image with one from HTC that appears to come with Google Voice Search, however now when I run from the emulator, i'm getting an Audio Problem message with Speak Again or Cancel buttons. It appears to make it back to the onActivityResult(), but the resultCode is 0.

Here is the LogCat output:

03-07 20:21:25.396: INFO/ActivityManager(578): Starting activity: Intent { action=android.speech.action.RECOGNIZE_SPEECH comp={com.google.android.voicesearch/com.google.android.voicesearch.RecognitionActivity} (has extras) }

03-07 20:21:25.406: WARN/ActivityManager(578): Activity is launching as a new task, so cancelling activity result.

03-07 20:21:25.968: WARN/ActivityManager(578): Activity pause timeout for HistoryRecord{434f7850 {com.ikonicsoft.mileagegenie/com.ikonicsoft.mileagegenie.MileageGenie}}

03-07 20:21:26.206: WARN/AudioHardwareInterface(554): getInputBufferSize bad sampling rate: 16000

03-07 20:21:26.256: ERROR/AudioRecord(819): Recording parameters are not supported: sampleRate 16000, channelCount 1, format 1

03-07 20:21:26.696: INFO/ActivityManager(578): Displayed activity com.google.android.voicesearch/.RecognitionActivity: 1295 ms

03-07 20:21:29.890: DEBUG/dalvikvm(806): threadid=3: still suspended after undo (s=1 d=1)

03-07 20:21:29.896: INFO/dalvikvm(806): Uncaught exception thrown by finalizer (will be discarded):

03-07 20:21:29.896: INFO/dalvikvm(806): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@435d3c50 on ml_trackdata that has not been deactivated or closed

03-07 20:21:29.896: INFO/dalvikvm(806):     at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)

03-07 20:21:29.896: INFO/dalvikvm(806):     at dalvik.system.NativeStart.run(Native Method)

03-07 20:21:31.468: DEBUG/dalvikvm(806): threadid=5: still suspended after undo (s=1 d=1)

03-07 20:21:32.436: WARN/IInputConnectionWrapper(806): showStatusIcon on inactive InputConnection

I,m still not sure why I,m getting the Connect problem on the Droid. I can use Voice Search ok. I also tried clearing the cache, and data as described in some posts, butstill not working??

/**
* Fire an intent to start the speech recognition activity.
*/
private void startVoiceRecognitionActivity() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speech recognition demo");
startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
}

/**
* Handle the results from the recognition activity.
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
  // Fill the list view with the strings the recognizer thought it could have heard
  ArrayList<String> matches = data.getStringArrayListExtra(
  RecognizerIntent.EXTRA_RESULTS);
  mList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
matches));
}

super.onActivityResult(requestCode, resultCode, data);
}
Was it helpful?

Solution

Ok... problem fixed.

It appears you cannot use android:launchMode="singleInstance" when using the RecognizerIntent. I removed this from the manifest and the Voice Search runs correctly.

Thanks again Steve, for the info on USB debugging on the device. Very handy.

OTHER TIPS

You can also use android:launchMode="singleTask"

It works fine with VS.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top