1

Guys I am trying to make a voice recognition application in android, the application has one activity , I tried running the application on my samsung phone with Gingerbread OS, When voice button was pressed a connection error is displayed , I searched the following page regarding the error Voice Recognition Connection Error ,but it was not a help as my manifest file does not have a { android:launchMode "singleTask" } the code is as given below.Please help me with this.

package com.code.voice;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.speech.RecognizerIntent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Spinner;

public class VoiceActivity extends Activity implements OnClickListener {
/** Called when the activity is first created. */

Button b;
ListView lv; 
static final int check = 1111; 
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    b = (Button)findViewById(R.id.bPress);
    lv = (ListView)findViewById(R.id.lvReturnVoice);
    b.setOnClickListener(this);
}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,     RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    i.putExtra(RecognizerIntent.EXTRA_PROMPT, "You may begin ");
    startActivityForResult(i, check);

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub

    if(requestCode == check && resultCode == RESULT_OK)
    {
        ArrayList <String> results =   data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        lv.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,results));
    }
    super.onActivityResult(requestCode, resultCode, data);
}

}

enter image description here

Community
  • 1
  • 1
user47
  • 395
  • 1
  • 2
  • 16
  • problem solved , the voice testing application, basically runs on the google servers, I ran it without an net connection and that is why got these errors, but later it worked like a charm. – user47 Jul 23 '12 at 07:40

0 Answers0