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异常:地址家庭不是由协议错误支持!
答
我会猜这个。我认为,String filename = extras.getString("filename");
应更改为String filename = extras.getString("file://" + "filename");
请发布相关logcat
输出以帮助大家了解问题。
仍然是相同的错误日志cat:03-03 12:20:04.347:D/SntpClient(61):请求时间失败:java.net.SocketException:协议不支持的地址系列 – swapna 2012-03-03 06:50:47
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
我只是把它改成'file://' 对不起。请看看这是否有效。 – 2012-03-03 07:00:38