绑定到识别服务失败 [英] bind to recognition service failed

查看:1513
本文介绍了绑定到识别服务失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试VoiceRecognition.i已搜查,并没有发现任何可行的答案。
这里是code。

i am testing VoiceRecognition.i have searched and didn't find any feasible answer. here is the code.

import android.content.Intent;
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

import java.util.List;

public class MainActivity extends AppCompatActivity implements View.OnClickListener, RecognitionListener {

Button button;
SpeechRecognizer speechRecognizer;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    button = (Button) findViewById(R.id.button);
    speechRecognizer = SpeechRecognizer.createSpeechRecognizer(getApplicationContext());
    speechRecognizer.setRecognitionListener(this);
    button.setOnClickListener(this);
}

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

private static final int SPEECH_REQUEST_CODE = 0;

// Create an intent that can start the Speech Recognizer activity
private void displaySpeechRecognizer() {
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en");
    intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
            this.getPackageName());
    speechRecognizer.startListening(intent);

}
@Override
protected void onActivityResult(int requestCode, int resultCode,
                                Intent data) {
    if (requestCode == SPEECH_REQUEST_CODE && resultCode == RESULT_OK) {
        List<String> results = data.getStringArrayListExtra(
                RecognizerIntent.EXTRA_RESULTS);
        String spokenText = results.get(0);
        System.out.println(spokenText);
        // Do something with spokenText
    }
    super.onActivityResult(requestCode, resultCode, data);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.button:
            displaySpeechRecognizer();
            break;
    }

}

@Override
public void onReadyForSpeech(Bundle params) {
    System.out.println("onReadyForSpeech");

}

@Override
public void onBeginningOfSpeech() {
    System.out.println("onBeginningOfSpeech");

}

@Override
public void onRmsChanged(float rmsdB) {
    System.out.println("onRmsChanged");

}

@Override
public void onBufferReceived(byte[] buffer) {
    System.out.println("onBufferReceived");

}

@Override
public void onEndOfSpeech() {
    System.out.println("onEndOfSpeech");

}

@Override
public void onError(int error) {
    System.out.println("onError");

}

@Override
public void onResults(Bundle results) {
    System.out.println("onResults");

}

@Override
public void onPartialResults(Bundle partialResults) {
    System.out.println("onPartialResults");

}

@Override
public void onEvent(int eventType, Bundle params) {
    System.out.println("onEvent");

}

}

和是这种布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textView" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="whats up"
    android:id="@+id/button"
    android:layout_below="@+id/textView"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="94dp" />

</RelativeLayout>

这里是清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.byteshaft.voicerecognition" >

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".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>

我得到这个错误
  - >voicerecognition E / SpeechRecognizer:绑定到识别服务失败
也找不到它的任何工作示例。

i am getting this error -> "voicerecognition E/SpeechRecognizer﹕ bind to recognition service failed " also cannot find any working example of it.

推荐答案

我刚刚跑过这个同样的问题,对我来说,问题是,我有我的手机上安装了CyanogenMod的一个版本,没有语音搜索安装。这里是我的步骤来解决它:

I just ran across this same issue and, for me, the problem was that I had a version of Cyanogenmod installed on my phone that didn't have Voice Search installed. Here are my steps to resolve it:


  1. 下载这个线程在XDA开发。该线程有如何安装该文件一个高层次的描述,但一步一步的在下面。

  2. 使用命令提示符(Windows)或shell窗口(Linux)上,运行位于您的Andr​​oid SDK /平台的工具文件夹中的应用,亚行

  3. 确保它可以通过运行以下命令谈谈您的设备 ADB设备如果您的设备没有列出,你需要确保的电话您的USB驱动程序正确的。

  4. 获得亚行的root访问权限。你可能已经有了,但执行 ADB根

  5. 执行亚行外壳
  6. 前往手机壳
  7. 找到对应使用命令执行cat / proc /坐骑为/系统在/ dev上市。您正在寻找的东西像的/ dev /块/ mtdblock4 /系统YAFFS2 RO,实时0 0

  8. 使用相应的/ dev下,重新挂载文件系统与命令读/写模式(我用上面的例子,但该模式应该是显而易见的)安装邻RW,重新挂载为/ dev /块/ mtdblock4 。回车,在命令退出亚行外壳退出

  9. 从您的计算机复制的apk到您的手机的push命令:亚行推C:\\ VoiceSearch.apk系统/应用程序

  10. 返回到亚行外壳采用亚行外壳并重新安装以只读方式存储(为了安全,你可以离开了这一点,如果你想)与安装邻滚装,重新挂载为/ dev /块/ mtdblock4 键,退出shell。

  1. Download the APK file from this thread in xda-developers. That thread has a high-level description of how to install that file but the step-by-step is below.
  2. Using a command prompt (windows) or shell window (linux), run the adb application located in your android sdk/platform-tools folder
  3. Ensure it can talk to your device by running the command adb devicesIf your device is not listed, you'll need to make sure your USB drivers for the phone are correct.
  4. Obtain root access through adb. You probably already have it but run adb root
  5. Go into the phone shell by executing adb shell
  6. Find the /dev listing that corresponds to "/system" using the command cat /proc/mounts. You are looking for something like /dev/block/mtdblock4 /system yaffs2 ro, realtime 0 0.
  7. Using the corresponding /dev entry, re-mount the file system into read/write mode with the command (I'm using the example above but the pattern should be obvious) mount -o rw,remount /dev/block/mtdblock4. Hit enter and exit adb shell with the command exit
  8. Copy the apk from your computer to your phone with the push command: adb push C:\VoiceSearch.apk system/app
  9. Go back in to adb shell using adb shell and re-mount the storage in read-only mode (for safety, you could leave this out if you wanted to) with mount -o ro,remount /dev/block/mtdblock4 and exit the shell.

就是这样。无需重新启动需要。您可以通过常规的谷歌搜索和击球的话筒按钮,看它是否启动测试。

That's it. No restart needed. You can test this by going to regular Google search and hitting the microphone button to see if it launches.

这篇关于绑定到识别服务失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆