Unable To Run Speechrecognizer Android

I seem to be not be able to run the speech recognizer on my phone. The app instals and the button is returning what it needs to be returning but the actual voice recognizer isn't returning onBeginning of Speech and etc... Here is my code, hopefully it's an easy fix. I am running on a Galaxy s3 which displays the erros (Trace: Can't open, no such directory) and ActivityManager: Warning: Activity not started, its current task has been brought to the front. May be a problem with permissions. Any help would be great!

public class MainActivity extends Activity implements OnClickListener {

ListView lv;
private SpeechRecognizer mSpeechRecognizer;
private Intent mSpeechRecognizerIntent; 

@Override
protected void onCreate(Bundle savedInstanceState) {


    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    lv = (ListView)findViewById(R.id.lvVoiceReturn);
    Button b= (Button)findViewById(R.id.bVoice);
    b.setOnClickListener(this);
    boolean available = SpeechRecognizer.isRecognitionAvailable(this);
    Log.d("Speech", "available = " + available);
    mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
    mSpeechRecognizer.setRecognitionListener(new SpeechListener());
    mSpeechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
            RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
            this.getPackageName());
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    Log.d("speech", "button active");
    mSpeechRecognizer.startListening(mSpeechRecognizerIntent);


}
private class SpeechListener implements RecognitionListener {


    @Override
    public void onBeginningOfSpeech() {
        Log.d("Speech", "onBeginningOfSpeech");
    }

    @Override
    public void onBufferReceived(byte[] buffer) {
        Log.d("Speech", "onBufferReceived");
    }

    @Override
    public void onEndOfSpeech() {
        Log.d("Speech", "onEndOfSpeech");
    }

    @Override
    public void onError(int error) {
        Log.d("Speech", "onError");
    }

    @Override
    public void onEvent(int eventType, Bundle params) {
        Log.d("Speech", "onEvent");
    }

    @Override
    public void onPartialResults(Bundle partialResults) {
        Log.d("Speech", "onPartialResults");
    }

    @Override
    public void onReadyForSpeech(Bundle params) {
        Log.d("Speech", "onReadyForSpeech");
    }


    @Override
    public void onResults(Bundle results) {
        Log.d("Speech", "results");

    }

    @Override
    public void onRmsChanged(float rmsdB) {
        //Log.d("Speech", "onRmsChanged");
    }

}

}

Here is my Manifest

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.RECORD_AUDIO"/> 

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.speech.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

Answers


You need the following permission

<uses-permission android:name="android.permission.RECORD_AUDIO"/>  

And fix the following error instead of

protected class mSpeechRecognizerIntent implements RecognitionListener  

it should be

private class SpeechListener implements RecognitionListener  

and add the following in onCreate after the line

boolean available = SpeechRecognizer.isRecognitionAvailable();
Log.d("Speech", "available = " + available);
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
mSpeechRecognizer.setRecognitionListener(new SpeechListener());

Need Your Help

How to deduce the count of the vacancies next to the name of the city?

php sql yii

I made a sql query that counts of jobs in a particular city

Hibernate NamedQuery and Pagination

java hibernate jpa pagination

I have my Entity with custom NamedQuery:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.