无法运行Speechrecognizer Android

无法运行Speechrecognizer Android,android,eclipse,Android,Eclipse,我似乎无法在手机上运行语音识别器。应用程序安装,按钮返回需要返回的内容,但实际的语音识别器在语音开始时没有返回,等等。。。这是我的代码,希望它很容易修复。我在Galaxy s3上运行,它显示了错误(Trace:Can't open,没有这样的目录)和ActivityManager:Warning:Activity not started,它当前的任务已经被放到了最前面。权限可能有问题。任何帮助都会很好 public class MainActivity extends Activity impl

我似乎无法在手机上运行语音识别器。应用程序安装,按钮返回需要返回的内容,但实际的语音识别器在语音开始时没有返回,等等。。。这是我的代码,希望它很容易修复。我在Galaxy s3上运行,它显示了错误(Trace:Can't open,没有这样的目录)和ActivityManager:Warning:Activity not started,它当前的任务已经被放到了最前面。权限可能有问题。任何帮助都会很好

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");
    }

}
<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>
}

<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>
这是我的舱单

<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>

您需要以下权限

<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>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>  
应该是

<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>
private class SpeechListener implements RecognitionListener  
并在行后的
onCreate
中添加以下内容

<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>
boolean available = SpeechRecognizer.isRecognitionAvailable();
Log.d("Speech", "available = " + available);
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
mSpeechRecognizer.setRecognitionListener(new SpeechListener());

操作系统的版本是什么?ICS还是JB?此外,在添加了用户权限后,还发布了您的声明,不幸的是,仍然没有收到任何方式的语音输入。我仍然会犯这些错误。我不知道现在发生了什么事。我真的非常需要这方面的帮助。不幸的是,我仍然没有获得公开的void onBeginingOfspeech(){Log.d(“Speech”,“onBeginingOfspeech”);}来表明操作正在开始。我正在将我的代码更新到目前为止的状态。你点击按钮后立即发言吗?差不多。。。。我想知道如果我在不同的设备上运行它会有什么不同?你建议怎么做?什么设备(预算)最适合与eclipse一起使用?