sabato 23 marzo 2013


HABEMUS MBC!


 FAST ANIMALS AND SLOW KIDS



Hi guys,

this evening I only suggest you an italian indie rock group, cause while you're programming you must stimulate your brain, and the music is the cheapest and most powerful exciting.
I often solve problems (about Android, informatics and not) just starting to listen to music, so...

However, I'm speaking of Fast Animals And Slow Kids.
I don't hear a sound like this from a very long time, and that's a very, very good thing, and I suggest especially three tracks A COSA CI SERVE, MARIA ANTOINETTA and TROIA, really beautiful. However, one must listen to the entire CD.
Morover it's FREE, and you can download the disc from 


Obviously you can either buy it in CD format and/or the VINYL from


Good listening!

HABEMUS MBC!


Ciao gente,

stasera vi consiglierò solo un gruppo indie rock italiano, poiché mentre programmate dovete stimolare il vostro cervello, e la musica è il più economico e potente eccitante.
Risolvo spesso problemi (su Android, di informatica e non) semplicemente ascoltando musica, quindi...

Comunque, sto parlando dei Fast Animals And Slow Kids.
Non sento un sound del genere da tanto tempo, ed è davvero una buonissima cosa, e vi segnalo tre tracce in particolare, A COSA CI SERVE, MARIA ANTONIETTA e TROIA, veramente belle. Comunque bisogna ascoltare tutto il CD.
Inoltre è GRATIS, e potete scaricare il disco da


Ovviamente potete anche comprarlo nel formato CD e/o VINILE da


Buon ascolto!

martedì 19 marzo 2013


HABEMUS MBC!


 HOW TO VALIDATE XML FROM XSD WITH NOTEPAD++ AND XMLTOOLS PLUGIN
-
COME VALIDARE UN XML DA UN XSD USANDO NOTEPAD++ E IL PLUGIN XMLTOOLS


Hi guys,

this evening I wanna only suggest you a quick trick for validating an XML from his XSD.

How you all know, XML is a markup language (it means eXtensible Markup Language), that means you can create your own structure of document ONLY defining the properties of the elements inside, and every "translator" can receive informations from it.
A raw method for translating XML docs is creating an XML parser by yourself: if you know the structure of the document, you can get all the infos you need.

But what if, for example, you expect an integer and you get a string instead? You get an "unbelievable" parsing error in every programming language known and unknown (at least as far as I know).

So what you need? A structured document containing the rules about every element of your xml. How it's long, which type it is, the chars admitted too!!!
In one word, you need an XSD document (Xml Schema Definition). You can create your own, by your hand or using a thousand tools, but in most cases, you'll create an XML and you'll need to validate it according to an existing XSD received by a third party, a customer or a web service.

At this point you have two choices:

  1. Create a parser that receive an XML and ITS XSD, and then check all XML elements according the rules included in XSD (that's a very good programming exercise about XML-XSD, but it needs time and it may not be helpful if you hurry);
  2. Find an existing tool or library that does it;
Because I'm always in a hurry, I've chosen the second.Googling for the web, I found that my favourite editor, Notepad++, has what I was looking for: a golden plugin that validate an XML from an XSD. His name is, with a lot of imagination, XML Tools.

Let's see how to get it.

If you have not, download Notepad++ from here. It's free. 
And now that the force is strong with you, install and open it.
Go in "Plugins -> Plugin Manager -> Show Plugin Manager", then scroll through the list and check "XML Tools". Click on install and wait a few seconds.
1.1 How to install XML Tools
Now you got XML Tools.
But how to use it? It's very quick and simple.
With this plugin you can do a lot of useful thing, like formatting your text using the "Pretty" functions, or "Enable auto-validation" at every saving...
However, first open your XSD document. Then go "Plugins -> XML Tools -> Validate now".

Doing that you can check that your XSD is well-formed. For example, a common error is "XML Parsing error at line XX: Extra content at the end of the document".
Then you go to the end of the document, and nothing: it's all ok... What the hell's happening?
Simple: you get THIS error:

1.2 XML Parsing error at line XX: Extra content at the end of the document
You see them? You have HORRIBLY KILLED two space blancks!
Correct them, and this error will disappear... Thank me: I've saved you an hour during a full emergency "deadline on arrival"!

Ok, now go on your XML. Click on "Validate now". If your XML can't reach the associated XSD, a prompt appear, and you must select the directory of the XSD. After that validate again: another dialog appears, and
  1. can tell you that the validation is successful;
  2. that you have an error, indicating the relative ELEMENT, the VALUE and the XSD RULE, in order to allow the immediate identification of the error (they could also indicate the line number, but that's okay...)
1.3 Showing the error 


Note that the dialog box may also not appear: but it happens ONLY when XML is validated.o
That's all. Bye!


venerdì 15 marzo 2013


HABEMUS MBC!


 HOW TO CREATE AN ANDROID PROJECT USING GOOGLE MAPS API V2
-
COME CREARE UN PROGETTO ANDROID USANDO LE GOOGLE MAPS API V2

Aaaaaaall right, folks.
This evening I decide to explain you how to create an Android Project using Google Maps API V2.
First of all let me say that using V2 API
  1. it's a bit harder then V1 API, cause the libs for Maps are not contained in a .jar archive, but must be imported as a project library;
  2. make your life easier while you programming your app's activities. The listeners have been optimezed, most of the logic has already been implemented, so the benefits are greater difficulties.
Let's start.

So you're already an Android Dev, you paid your life-long-fee, and you get your API KEY from your API CONSOLE.

Then open Eclipse, click on "Android SDK Manager", then check that "Google play services" is installed. If not, download it

1.1 How to check if you have Google Play Services
Ok, now you've got all you need to use maps.

- Create a new Android Project,

call it "Gennarino", or "Francis_FROM_Coppola" if you like it. Or "PrjBase" if you're indescribably boring. 

- Then go to your "androidManifest.xml" 

and add the highlighted strings, like in the pics below...

1.2 androidManifest.xml - ADDING PERMISSIONS AND OTHER SETTINGS

1.3 androidManifest.xml  - ADDING API KEY

... from which all of you can understand how boring I am... ;)
By the way, let's stop a moment for explaining.
  • <permission       
    android:name="prjbase.main.permission.MAPS_RECEIVE"
            android:protectionLevel="signature" />
    It means that you ask to your OS the permission for receiving MAPS, using a "signature" (your API KEY);
  •  <uses-feature     android:glEsVersion="0x00020000"
  •      android:required="true" />

  • That's indicates the openGL ES version (in this case the 2, look in the middle of 0), and if it's required;
  • <uses-permission ...../>Those strings are simples, and are similar to permission in the use; they indicate which permission this app is authorized to use;
  •  <meta-data           
    android:name="com.google.android.maps.v2.API_KEY"
                android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />      
  • Here you must put your API KEY V2 instead of xxx...

- LET'S MODIFY OUR map.xml VIEW

adding a fragment that will contain our map. Google ha decided to use MapFragments instead of MapView, probably for increasing performances. However that is, so do like in the pic

1.4 Adapting you map view

Ok, we have updated the manifest, and added the fragment to the view. Now we have to

- IMPORT google-play-services_lib AS A PROJECT LIB

First of all we have to right click on the white space of our package explorer, then select import and choose "EXISTING ANDROID CODE INTO WORKSPACE"; 

BE CAREFUL: DON'T "EXISTING PROJECT INTO WORKSPACE"!!!


Then browse into you android-sdk directory, and go into

<your_android-sdk_DIRECTORY>\extras\google\google_play_services\libproject

 and click on finish.

1.5 How to import google-play-services_lib as project lib

Wow! You're great! That was the worst! Now let's see how 

- ADD THIS LIB INTO OUR PROJECT 

Yes, OUR, not YOUR, cause I've teached you how to make it, and your project is mine too!
So right click on OUR project, click on Properties, then Android tab. Go down after your list of Android devices, and finally you've reached the Library section.
Click on "Add" button, and select "google-play-services_lib", then OK.

1.6 Add google-play-services_lib into our project

WELL DONE, DELTA!
Now we must only

- LOAD OUR MAP FRAGMENT INTO OUR ACTIVITY

simply using this commenda, right after setContentView(R.layout.map);

map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map_view)).getMap();

Let me say that the map is a private GoogleMap map; put outside the method onCreate(), into the Activity. Here is the code of map Activity

giovedì 14 marzo 2013

 HABEMUS MBC!


 HOW TO SOLVE THE HORRIBLE ANDROID BUG CREATED FROM LAUNCHING AN .XML FILE (OBTAINING AN .OUT.XML FILE AND A THOUSAND ERRORS)
-
COME RISOLVERE L'ORRIBILE BUG ANDROID CREATO DAL LANCIARE UN FILE .XML (OTTENENDO UN FILE .OUT.XML E UN MIGLIAIO DI ERRORI)

Ok Guys. Hi Everyone.
Today I will tell you how to solve that horrible, horrorful, fearing, creepy, damned error that happens when you, keeping in mind 20-30 variables at the same time (human's standard is 4-8), decide to launch your app project and... You're XML VIEW IS OPEN!

1.1 The horrible, horrorful, fearing, creepy, damned error!!!
Keep calm.
Don't destroy your pc like I've done in "those 3 days"...
First of all you must know that you can avoid this bug downloading the last updates of Android sdk. With these, Eclipse don't launch the XML as an application, so you will not have this problem.
But you're obviously unlucky, even lazy, and you love you're working version of Eclipse... Android SDK... Why, why upgrading?

So this's for you. pc-Republicans.
You must simply delete the new generated .out.xml file  -->   <your_file_name>.out.xml.

So easy?
Yes, BUT you can encounter other errors...
First of all, eclipse can decide not to delete the damned file. In this case you must close Eclipse, go in your project directory, and clean you're file manually.
BUT now is time for java pending process... Yes, cause you've closed Eclipse BUT you haven't kill javaw.exe process. SO follow the image steps after saving all you're java-based programs, and after closing Eclipse & Netbeans
1.2 Kill javaw.exe

  1. Right click on application bar;
  2. Select Task Manager;
  3. Search for javaw.exe process in the process tab, then right click on it (ATTENTION! IT COULD BE CLOSED YET, SO YOU CAN'T APPLY THIS METHOD);
  4. Select Kill process;
Now your file is free. And you can finally delete him. You can even use ninja sword, if you have lost one eye.

And now? I've opened Eclipse, and is full of errors!!!
Yes, you're really unlucky. But you can solve it modifing one file and saving the project.  The billion's of error are caused from your R.java file. His task is to save all references of project resources, and when you have launched the xml file (nooooob) you drive Eclipse crazy. So Eclipse delete R.java and try to rebuild it (cause is an auto-generated file), but because of the errors could not.
But now the error is no more, so Eclipse is again able to rebuild R.java! AH-AAH!

...

NOOOOOO! IT CAN'T BE...
Yes... It can... You've established a Guinness World Record. 
By the way, the final step could be one of this two:
  1. Pasting another R.java. If you're lucky, Eclipse will update it, and you've saved you work;
  2. Creating another project, pasting ONLY you're activity classes, you're graphics/colors/array/strings resources and your jars. It's annoying, but it could save your sleep...
  3. Praying all known Gods, existed and not. Or challenge them. For sure you'd be lucky
That's all, folks!
Bye!

_________________________________________________________________________________

 HABEMUS MBC!

Ok gente. Ciao a tutti.
Oggi vi racconterò come risolvere quell'orribile, orrorifico, spaventoso, raccapricciante, dannato errore che accade quando, tenendo a mente 20-30 variabili contemporaneamente (lo standard umano è di 4-8), decidete di lanciare il vostro progetto e... LA VOSTRA VISTA XML E' ANCORA APERTA E SELEZIONATA!
Today I will tell you how to solve that horrible, horrorful, fearing, creepy, damned error that happens when you, keeping in mind 20-30 variables at the same time (human's standard is 4-8), decide to launch your app project and... You're XML VIEW IS OPEN AND SELECTED!

1.1 L'orribile, orrorifico, spaventoso, raccapricciante, dannato errore
State calmi.
Non distruggete il vostro pc come ho fatto in "quei 3 giorni"...
Prima di tutto dovete sapere che potete evitare questo bug scaricando gli ultimi aggiornamenti dell'Android SDK. Con questi, Eclipse non lancerà l'XML come un'applicazione, quindi non avrete questo problema.
Ma ovviamente siete sfortunati, anche pigri, e amate la vostra versione funzionante di Eclipse... L'Android SDK... Perché, perché aggiornare?

Quindi questo è per voi, pc-Repubblicani.
Dovete semplicemente cancellare il nuovo file .out.xml generato  -->   <tuo_nome_file>.out.xml.

E' così facile?
Si, MA potreste imbattervi in altri errori...
Prima di tutto, Eclipse può decidere di non cancellare il dannato file. In questo caso dovete chiudere Eclipse, andare nella cartella del progetto, e cancellare il file manualmente.
MA ora è il turno del processo java ancora attivo... Si, perché avete chiuso Eclipse MA non avete terminato il processo javaw.exe. Quindi seguite gli step nell'immagine DOPO aver salvato tutti i vostri programmi basati su java, e dopo aver chiuso Eclipse e Netbeans.

1.2 Kill javaw.exe

  1. Click destro sulla barra delle applicazioni;
  2. Selezionate "Avvia Gestione attività";
  3. Cercate il processo javaw.exe nel tab dei processi, quindi cliccateci sopra col tasto destro (ATTENZIONE: POTREBBE GIA' ESSERE CHIUSO, E QUINDI QUESTA PROCEDURA NON E' APPLICABILE);
  4. Selezionate "Termina processo";
Ora il vostro file è libero. E potete finalmente cancellarlo. Potete anche usare una spada ninja, se avete perso un occhio.

E adesso? Ho aperto Eclipse, ed è pieno di errori!!!
Si, sei davvero sfortunato. Ma puoi risolvere modificando un file a caso e salvando il progetto. I miliardi di errori sono causati dal tuo file R.java. Il suo compito è di salvare tutti i riferimenti delle risorse del progetto, e quando hai "lanciato" il file xml (nooooob) hai fatto impazzire Eclipse. Quindi Eclipse ha cancellato R.java e ha provato a ricostruirlo (perché è un file auto-generato), ma a causa degli errori non ha potuto.
Ma ora l'errore non c'è più, quindi Eclipse è di nuovo capace di ricostruire R.java! AH-AAH!

...

NOOOOOO! Non può essere...
Si... Può essere... Hai stabilito un Guinness World Record.
Comunque, il passo finale può essere uno di questi due:
  1. Incollare un altro R.java. Se sei fortunato, Eclipse lo aggiornerà, e avrete salvato il vostro lavoro;
  2. Creare un altro progetto, incollando SOLO le vostre classi Activity, le vostre risorse grafiche/colors/array/strings e i vostri jar. E' noioso, ma potrebbe salvarvi il sonno.
  3. Pregare tutti gli Dei noti, esistiti o meno. O sfidarli. Di sicuro sareste più fortunati!
That's all, folks!
Ciao!

mercoledì 13 marzo 2013

Non è possibile visualizzare le mappe dopo la pubblicazione su Google Play - Can't see maps after publishing App on Google Play

HABEMUS MBC!

 PILLOLE DI PROGRAMMAZIONE -  INFORMATICA - TECNOLOGIA - TRUCCHI DEL MESTIERE & CO!
-
PROGRAMMING TRICKS - INFOMATICS- TECHNOLOGY- TRICKS OF THE TRADE & CO!

Benvenuti + Non è possibile visualizzare le mappe dopo la pubblicazione su Google Play
-
Welcome + Can't see maps after publishing App on Google Play

Ciao a tutti ragazzi, con questo post dichiaro ufficialmente aperto il mio blog. Proprio oggi che hanno eletto il Papa io decido di ritagliarmi il mio spazio di notorietà sul web.
Megalomane? Megalomane, esatto.
Ad ogni modo, di tanto in tanto posterò la soluzione a dei problemi informatici che mi hanno fatto impazzire, o a qualche tecnica di scommessa, comunque tenterò di scrivere sempre qualcosa di utile, ovviamente sia in italiano che in inglese e, per quanto riguarda la traduzione, nei limiti della mia ignoranza.
Ma con una differenza rispetto a questo post: l'ordine sarà invertito.
Ciò mi serve ad ottenere più visibilità e, comunque, se siete programmatori credetemi: almeno saperlo leggere vi servirà come l'aria, quindi prima vi abituate e meglio è!

Per cominciare una chicca per i programmatori Android che si stanno affacciando alle mappe di google. In particolare alle Google MAPS API V2, che rivoluzionano e semplificano notevolmente il lavoro di noi poveri smanettoni.

Vi sarà capitato, subito dopo aver pubblicato la vostra app su Google Play, di non riuscire a visualizzare la mappa.
Ciò accade per il seguente motivo.
Nelle istruzioni che Google offre a noi developer, e in tantissimi forum e tutorial, viene suggerito di inserire, nella schermata 1.1

1.1 Configurare Android Key per API Project

un identificatore che unisce la vostra chiave SHA1 e il nome del package della vostra app.
Questa funzione serve per consentire alle sole applicazioni indicate nel campo di testo di ricevere le mappe. Se da un lato può essere utile, alle volte può provocare il problema di cui sopra.
Quindi, se avete questo problema, togliete l'id univoco che avete inserito dal campo dell'immagine 1.1! In questo modo tutte le app che utilizzeranno quella chiave potranno usufruire delle mappe, senza filtro alcuno.

Ma come MBC, ho fatto come dici, ma non funziona ancora?
In questo caso, escludendo errori di setting del progetto (che potete risolvere seguendo il tutorial di Lars Vogel, che personalmente consiglio caldamente), avete probabilmente adattato un progetto che utilizzava le vecchie API V1 alle API V2 (come ho fatto io per la mia App SCOLACIUM).

In questo caso vi informo di due cose:

  1. Se alla data del 03/03/2013 avete richiesto una chiave per le GMaps API V1, allora potete utilizzare ancora quell'app;
  2. Se non siete così fortunati, e avete realizzato con tanto sudore un'app con le API V1 ma NON AVETE RICHIESTO LA CHIAVE PRIMA DI QUELLA DATA, dovrete riprogrammare il vostro progetto con le nuove API (non è una cosa impossibile né difficile, ma ci vuole un po' di tempo per via di qualche passaggio "non canonico". Comunque tranquilli: tra qualche giorno pubblicherò un breve tutorial a riguardo).

Ciò perché Google ha terminato il supporto alle API V1 il 03/03/2013, e quindi non offre più chiavi per le mappe di questa versione. Però continuerà a supportare le chiavi delle app già assegnate fino a quella data.

Bene, per oggi è tutto.
Spero di avervi restituito un po' di sonno con il vostro progetto GMaps. Se così non fosse, spero di poterlo fare con il tutorial a venire.

Buona serata.
HABEMUS MBC!
_________________________________________________________________________________

Hi everyone, with this post i officially declare open my blog! Just today that new Pope was elected, I've decided to cut out my web-fame-space.
Megalomaniac? Megalomaniac, "right right right".

By the way, sometimes I'll post the solution for some programming problems drive me crazy, or for some betting tecnique... However I'll try to write always something useful, obviously both Italian and English and, regarding the translation, within the limits of my ignorance.
But with a difference to this post: the order will be inverted, first English than Italian.
I need this for obtaining a greater visibility and, however, if you're programmer or computer science engineer believe me: being able to read English will be compulsory for you, so that the faster you get used to the better is!

To begin a tip for those Android programmers that are approaching to google Maps. In particular to the Google MAPS API V2, that revolutionize and significantly simplify our poor geek-work.

So you're reading this post. For this reason, I suppose after publishing your app on Google Play you're not being able to view the map.
This occurs for the following reason.
In the tutorials Google offers us developers, and in many other forums, it's suggested to include into your API CONSOLE an identifier that combines your key SHA1 and the package name of your app, see the screenshot 1.1


1.1 Configure Android Key for API Project
This function is used to allow only applications specified in the text field to receive the maps.
If, by one side, it can be useful, from the other can sometimes cause the problem previously mentioned.
So, if you've this problem, remove the unique id that you have entered into the textfield of image 1.1!
In this way, every app that use that key will be able to obtain maps, without any filter!


But how is it possible, MBC, I've done as you say, but still doesn't work?
In this case, excluding  errors about setting your project (you can solve following this Lars Vogel's tutorial, I personally strongly suggest it), you've probably adapted a project that used the old API V1 to API V2 (like I've done for my app SCOLACIUM).

So i inform you about two things:

  1.  If at the date 2013/03/03 you've requested an GMaps API V1 key, so you can use and release your app yet;
  2. If you're not so lucky, and you've realized with much sweat an app with API V1 but YOU DON'T HAVE REQUESTED THE KEY  BEFORE THAT DATE, you have to reprogramming your project with the new API (it's not something impossible or difficult, but it takes a little time because of some "non-canonical"  passage. By the way stay up: in a few days I'll publish a short tutorial about it).

This is because Google has ended support for V1 API on 03/03/2013, and so it offers no more keys for this version of API maps. However, Google will support the keys for the already assigned app to that date.

Well, that's all, folks!
I hope you've returned a little sleep with your GMaps project. If not, I hope to do with the tutorial to come.

Good evening.
HABEMUS MBC!