Java
Google API getFromLocationName throws IOException
by gurucoder on Nov.08, 2011, under Android, Java
If you are using the Google GPS API for Android you could encounter an IOException for “Service Not Available” , calling the method getFromLocationName() of the GeoCoder class.
This method should be able, given a location name, to retrieve an array of Address objects related to the specified string.
Sometimes the mehod works pretty good, but others the exception is thrown.
The Solution
Here there is a long discussion about the issue:
http://code.google.com/p/android/issues/detail?id=8816
On comment 21 there the workaround calling the web api directly and retrieving data using a JSON object.
Hopefully the google api for android will be fixed soon…
How to Change the Android ListView divider color
by gurucoder on Nov.08, 2011, under Android, Java
If you need to change the divider colo in an android ListView view, all you need to do is to add the following code inside the xml layout file
<ListView
android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="#FFCC00"
android:dividerHeight="1px"/>
In this way you have applied the #FFCC00 color to the divider.
It is important to reset the divider height after changing the color or the divider will be hidden.
Java Preferences on Mac OS
by gurucoder on Jul.14, 2011, under Java, Mac
While on Windows the Java Preferences keys are stored inside the system registry ( regedit ), under MAC OS it is far more simple to get access to that info.
The preferences files generated by the Preferences API are named com.apple.java.util.prefs.
The user’s preferences file is stored in their home directory (~/Library/Preferences/).
The system preferences are stored in /Library/Preferences/ and are only persisted to disk if the user is an administrator.
Skype-Java-Api 1.1 the new Java API for Skype
by gurucoder on Jul.11, 2011, under Java
If someone wants to integrate Skype services and functionalities inside a Java program, the best Java API it’s always been Skype4Java. The problem is that the library has not been updated since 2006 and it is quite old to fully manage all the Skype features and it is not compatible with Java 64 bit installations.
BUT now the things are changed!!!
Thanks to Gabriel Takeuchi, Skype4Java revives with a new name and version!
skype-java-api 1.1
The library starts to be a clone of the old Skype4Java, solving some bugs and adding new features and methods:
getLanguageByISOCode()
is an example that permits to get the user language returning the language ISO code and not its full name.. I think it is a really useful method!
( Italian -> it )
The library is compatible with Windows , Linux 64bit and MacOs but soon it will be compatible also with Linux 32bit as well.
Any reference to SWT library have been erased making this peace of software more fast and reliable.
Here it is the link for the download from Maven repo and here it is the link to the developer blog .
Come utilizzare MBROLA con FreeTTS in Java
by gurucoder on Jun.05, 2010, under Java
In generale il riconoscimento vocale puo essere logicamente suddiviso in due aspetti: Sintesi e Riconoscimento.
L` implementazione di un servizio TTS (Test To Speech) in Java puo essere realizzata utilizzando le JSAPI realizzate dalla Sun di cui ne esiste una implemntazione free denominata FreeTTS.
FreeTTS offre solo i servizi di Sintesi, ignorando completamente l` aspetto legato al riconoscimento vocale.
In fase di sintesi, FreeTTS offre un set di voci decisamente metalliche e poco gradevoli tra cui quella di default e` denominata kevin16. L` idea e` di dotare il nostro software dell` utilizzo anche di un set di voci piu` “umane” importate dalle librerie MBROLA.
Sebbene non tutte siano supportate da FreeTTS ecco di seguito il codice Java necessario allo scopo:
The jars are available in the FreeTTS download page in the FreeTTs Bin Zip File at
http://sourceforge.net/project/showfiles.php?group_id=42080&package_id=34183&release_id=311626
System Classpath + User Classpath
C:\Program Files\Java\jdk1.5.0_06\lib\jsapi.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\cmulex.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\mbrola.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\freetts.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\en_us.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\cmutimelex.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\cmudict04.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\cmu_time_awb.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\cmu_us_kal.jar;
User Path
C:\Program Files\Java\jdk1.5.0_06\lib
/**
* Copyright 2003 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and
* redistribution of this file, and for a DISCLAIMER OF ALL
* WARRANTIES.
*/
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
import com.sun.speech.freetts.audio.JavaClipAudioPlayer;
/**
* Simple program to demonstrate the use of the FreeTTS speech
* synthesizer. This simple program shows how to use FreeTTS
* without requiring the Java Speech API (JSAPI).
*/
public class FreeTTS
{
VoiceManager voiceManager;
Voice voice;
public FreeTTS() {
}
public void TTS(String words)
{
String voiceName = "mbrola_us3";
//String voiceName = "kevin16";
// System.out.println();
//System.out.println("Using voice: " + voiceName);
// The VoiceManager manages all the voices for FreeTTS.
voiceManager = VoiceManager.getInstance();
voice = voiceManager.getVoice(voiceName);
/* Voice[] voices = voiceManager.getVoices();
for (int i = 0; i < voices.length; i++) {
System.out.println("" + voices[i].getName()+ " (" + voices[i].getDomain() + " domain)");
}*/
if (helloVoice == null)
{
System.err.println("Cannot find a voice named " + voiceName + ". Please specify a different voice.");
System.exit(1);
}
// Allocates the resources for the voice.
voice.allocate();
//Synthesize speech.
voice.speak(words);
// Clean up and leave.
voice.deallocate();
// System.exit(0);
}
}



