【问题标题】:Android app Address family not supported by protocol error?协议错误不支持Android应用地址系列?
【发布时间】:2012-03-21 14:13:51
【问题描述】:

我的代码:

private static final String TAG = "TextToSpeechDemo";

private TextToSpeech mTts;
private Button mAgainButton;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
 setContentView(R.layout.speak);


TextToSpeech mTts = new TextToSpeech(this,this);
 // Initialize text-to-speech. This is an asynchronous operation.
// The OnInitListener (second argument) is called after initialization completes.
mTts = new TextToSpeech(this,
    this  // TextToSpeech.OnInitListener
    );

// The button is disabled in the layout.
// It will be enabled upon initialization of the TTS engine.
mAgainButton = (Button) findViewById(R.id.again_button);

mAgainButton.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        sayHello();
    }
});


@Override
public void onInit( int status) {
    // TODO Auto-generated method stub
    // status can be either TextToSpeech.SUCCESS or TextToSpeech.ERROR.
    if (status == TextToSpeech.SUCCESS) {
    // Set preferred language to US english.
    // Note that a language may not be available, and the result will indicate this.
    int result = mTts.setLanguage(Locale.US);
    // Try this someday for some interesting results.
    // int result mTts.setLanguage(Locale.FRANCE);
    if (result == TextToSpeech.LANG_MISSING_DATA ||
    result == TextToSpeech.LANG_NOT_SUPPORTED) {
    // Language data is missing or the language is not supported.
    Log.e(TAG, "Language is not available.");
    } else {
    // Check the documentation for other possible result codes.
    // For example, the language may be available for the locale,
    // but not for the specified country and variant.
    // The TTS engine has been successfully initialized.
    // Allow the user to press the button for the app to speak again.
    mAgainButton.setEnabled(true);
    // Greet the user.
    sayHello();
}
    }
    else {
        // Initialization failed.
        Log.e(TAG, "Could not initialize TextToSpeech.");
        }
        }
private void sayHello() {
    Bundle extras = getIntent().getExtras();

    String filename = extras.getString("filename");
    String filecontent = extras.getString("filecontent");
    mTts.speak(filecontent,
    TextToSpeech.QUEUE_FLUSH, // Drop all pending entries in the playback queue.
    null);
    }

它显示 03-03 12:01:21.778: D/SntpClient(61): request time failed: java.net.SocketException: Address family not supported by protocol error!!!

【问题讨论】:

    标签: android


    【解决方案1】:

    我会猜测一下。我觉得,String filename = extras.getString("filename");应该改成String filename = extras.getString("file://" + "filename");

    请贴出相关的logcat输出,帮助大家理解问题。

    【讨论】:

    • 还是一样的错误日志 cat:03-03 12:20:04.347: D/SntpClient(61): request time failed: java.net.SocketException: Address family not supported by protocol
    • nw 显示:03-03 12:24:22.106:W/KeyCharacterMap(413):使用默认键盘映射:/system/usr/keychars/qwerty.kcm.bin 和 03-03 12: 24:22.106: W/KeyCharacterMap(413): id 0 没有键盘
    • 我刚把它改成file:// 抱歉打错了。请看看这是否有效。
    猜你喜欢
    • 2019-02-01
    • 1970-01-01
    • 2012-12-03
    • 1970-01-01
    • 2013-02-04
    • 2021-01-05
    • 2018-11-01
    • 2013-12-20
    • 1970-01-01
    相关资源
    最近更新 更多