2012-03-03 86 views
0

我的代碼: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); 
    } 

它顯示12月3日至3日:01:21.778:d/SntpClient(61):請求時間失敗:java.net.SocketException異常:地址家庭不是由協議錯誤支持!

回答

0

我會猜這個。我認爲,String filename = extras.getString("filename");應更改爲String filename = extras.getString("file://" + "filename");

請發佈相關logcat輸出以幫助大家瞭解問題。

+0

仍然是相同的錯誤日誌cat:03-03 12:20:04.347:D/SntpClient(61):請求時間失敗:java.net.SocketException:協議不支持的地址系列 – swapna 2012-03-03 06:50:47

+0

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 – swapna 2012-03-03 06:57:06

+0

我只是把它改成'file://' 對不起。請看看這是否有效。 – 2012-03-03 07:00:38

相關問題