2012-03-03 17 views
0

私のコード:Androidアプリアドレスファミリはプロトコルエラーでサポートされていませんか?

プライベート静的最終文字列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が:プロトコルエラーによってサポートされていないアドレスファミリー!

答えて

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

+0

nw its showing: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

+0

私はそれを 'file://'に変更しました 誤字を犯しました。これが機能するかどうか確認してください。 –

関連する問題