协议错误不支持Android应用地址系列?

时间:2012-03-03 06:31:51

标签: android

我的代码:

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):请求时间失败:java.net.SocketException:协议错误不支持地址族!!!

1 个答案:

答案 0 :(得分:0)

我会猜测一下。我认为,String filename = extras.getString("filename");应更改为String filename = extras.getString("file://" + "filename");

请发布相关的logcat输出,以帮助每个人了解问题。