Archivi tag: java

Failed to create the Java Virtual Machine – How To

Ok, avete installato Eclipse ma al momento della partenza l’unico messaggio che ricevete è il seguente:
“Failed to create the Java Virtual Machine”
Significa solo che avete fatto qualche casino con l’installazione della JDK (magari l’avete installata dopo aver avviato eclipse per la prima volta), ma non è un problema, basta editare il file eclipse.ini che trovate nella stessa cartella dove c’è l’eseguibile eclipse.exe ed aggiungiate con i giusti percorsi il seguente comando:

-vm C:\Program Files\Java\jre6\bin\javaw

chiudete tutto, salvate
e … buona programmazione

al prossimo tip! 😀

[ANDROID] Screen always turned on How to

This android code snippet is for keep alive the screen of your android device during the execution of your app, please read the note also.

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
wl.acquire();

..screen will stay on during this section..

wl.release();

IMPORTANT: Remember to RELEASE the WakeLock when you have finished to use it, otherwise the screen will be ever turned on! 🙂

Android Color List

if you write android code you will need as soon as possible of a list of colors, i’ve found this that i think is very exaustive, you don’t think so? 🙂

 


< ?xml version="1.0" encoding="utf-8"?>

#FFFFFF #FFFFF0 #FFFFE0 #FFFF00 #FFFAFA #FFFAF0 #FFFACD #FFF8DC #FFF5EE #FFF0F5 #FFEFD5 #FFEBCD #FFE4E1 #FFE4C4 #FFE4B5 #FFDEAD #FFDAB9 #FFD700 #FFC0CB #FFB6C1 #FFA500 #FFA07A #FF8C00 #FF7F50 #FF69B4 #FF6347 #FF4500 #FF1493 #FF00FF #FF00FF #FF0000 #FDF5E6 #FAFAD2 #FAF0E6 #FAEBD7 #FA8072 #F8F8FF #F5FFFA #F5F5F5 #F5F5DC #F5DEB3 #F4A460 #F0FFFF #F0FFF0 #F0F8FF #F0E68C #F08080 #EEE8AA #EE82EE #E9967A #E6E6FA #E0FFFF #DEB887 #DDA0DD #DCDCDC #DC143C #DB7093 #DAA520 #DA70D6 #D8BFD8 #D3D3D3 #D2B48C #D2691E #CD853F #CD5C5C #C71585 #C0C0C0 #BDB76B #BC8F8F #BA55D3 #B8860B #B22222 #B0E0E6 #B0C4DE #AFEEEE #ADFF2F #ADD8E6 #A9A9A9 #A52A2A #A0522D #9ACD32 #9932CC #98FB98 #9400D3 #9370DB #90EE90 #8FBC8F #8B4513 #8B008B #8B0000 #8A2BE2 #87CEFA #87CEEB #808080 #808000 #800080 #800000 #7FFFD4 #7FFF00 #7CFC00 #7B68EE #778899 #708090 #6B8E23 #6A5ACD #696969 #66CDAA #6495ED #5F9EA0 #556B2F #4B0082 #48D1CC #483D8B #4682B4 #4169E1 #40E0D0 #3CB371 #32CD32 #2F4F4F #2E8B57 #228B22 #20B2AA #1E90FF #191970 #00FFFF #00FFFF #00FF7F #00FF00 #00FA9A #00CED1 #00BFFF #008B8B #008080 #008000 #006400 #0000FF #0000CD #00008B #000080 #000000

Download Remote File Android

[ITA] Ecco uno snippet di codice utile per poter scaricare un file localizzato su un server remoto
[ENG] This is a code snippet useful to download a file


public String downloadURL (URL url, String fileName) throws IOException {
String destination = null;

try {
destination = Environment.getExternalStorageDirectory() + "/"
+ "myapp/" + fileName;

InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream(destination);

byte buffer[] = new byte[1024];
int bytes = 0;

while ((bytes = input.read(buffer)) != -1) {
output.write(buffer,0, bytes);
}

output.flush();
output.close();
input.close();

}
catch (Exception e) {
Log.e("DOWNLOAD URL", "downloading file failed due to " + e.toString());
}

return destination;
}