The Blog

➤ How to add footer to NavigationView

28 Ago 15

NavigationView was recently added by the Android support team to help developers deliver consistent NavigationDrawer Menu across apps. It’s usage is super simple thanks to its support of native menu’s xml resource files.

Such simplicity comes with a drawback. You can add menu items, an header but not a footer. After investigating a little I saw the NavigationView actually uses a ListView to display the menu and the given header is added through the ListView.addHeaderView method.

Read More

How to avoid Fragments overlapping due to backstack nightmare in android

16 Ago 15

Recognize this mess above?? That WTF moment that happens when you’re trying to do nothing special?

This screenshot was taken after pressing the back button after a specific set of preconditions have occurred:

  • You committed a FragmentTransaction without “addToBackStack”
  • You did not set the background color to the rootview of your fragments (Good boy)
  • you tried to go back just after adding the above mentioned transaction.

Let me explain:

Lets assume we’ve 3 fragments: A, B, C. and you’d like to have the following behavior: User navigates in the following direction A -> B -> C; Suddenly you realize you’d like to skip “B” from the back stack letting the user jump from “C” to “A” when pressing the back button. What would you do?

Read More

Miglior Smartphone Android – Come sceglierlo

03 Giu 15

Rotto il vostro smartphone o è semplicemente  arrivato il momento di cambiarlo? Periodicamente ci si ritrova con il problema di andare a scegliere il miglior smartphone che fa per voi.

Purtroppo online c’è molta confusione a riguardo e moltissime volte vi ritroverete a leggere decine e decine di recensioni per poi non capirci più nulla.

Fortunatamente lo staff di androidiani.com mantiene costantemente una classifica dei migliori smartphone android sul mercato. Questa classifica, anche se non definitiva, vi aiuterà a restringere il campo di ricerca a pochi telefoni invece che continuare a navigare nel buio tra schede tecniche e opinioni personali fatte da diverse persone.

La classifica si presenta in modo chiaro e conciso ed è suddivisa in fasce di prezzo. Avrete così modo di considerare solo i migliori smartphones per fascia di prezzo. Attualmente le fasce proposte dallo staff di androidiani per miglior smartphone android sono:

Buon acquisto!

Recensione WeBank opinioni negative e positive

12 Gen 15

Sono sempre stato un fan delle banche online. Da quando ne ho avuto la possibilità ho aperto immediatamente un conto iwBank e, portato dalla curiosità, ho aperto qualche tempo fa anche un conto webank.

Andiamo con ordine con alcune considerazioni generali su webank.

Apertura del conto Webank

L’apertura del conto è praticamente uguale per tutte le banche online. Vi verrà richiesto di stampare dei contratti, firmarli, allegare uno o piu documenti di riconoscimento ( Carta identità o passaporto ) e spedirli.

Una volta fatto ciò dovrete attendere che le carte arrivino presso Webank e che quest’ultima processi le carte comunicandovi ogni cambio di stato. Il tempo di apertura conto webank è di circa 2 settimane anche se dipende da vari fattori come la correttezza dei contratti e eventuali giorni festivi che intercorrono tra l’invio dei documenti e il “processing” della banca.

L’interfaccia grafica

Essendo Webank una banca online l’interfaccia grafica è tutto. Il tutto è presentato in maniera semplice e chiara. Ogni sezione del sito è categorizzata e anche se a prima vista potrebbe sembrare una “marea” di pagine, dopo alcuni giorni di utilizzo il tutto diventerà meccanico e molto intuitivo.

Avrete la possibilità di effettuare l’accesso in due modalità:

  • sola lettura
  • dispositiva: permettendovi di fare azioni come pagamenti, ricariche e bonifici

Quest’ultimo, anche se può sembrare inutile, presenta un incrementato fattore di sicurezza qualora dovreste “entrare” nell’home-banking da posti non sicuri (come un internet cafè o un luogo pubblico). Infatti, entrando in modalità sola lettura, anche se qualche mal’intenzionato riuscisse a rubarvi l’accesso non potrebbe comunque fare nulla di dispositivo.

L’accesso al sito

L’accesso al sito avviene tramite una username (fornita da webank) e una password (scelta da voi). Una volta convalidato il login vi sarà richiesto di effettuare un’ulteriore verifica inserendo la vostra data di nascita ed eventualmente porzioni del token.

Il token è quel dispositivo che vi fornisce dei codici temporanei e che voi dovreste custodire con cura. Praticamente tutte le operazioni dispositive necessitano del token.

Nel caso mio, Webank ha fornito una tessera contenente 32 codici pre-stampati e al login verranno richieste due cifre di uno di questi 32 codici presenti nella tessera formato carta di credito.

Opinioni negative webank

Il token pre-stampato

Il token pre-stampato non è il massimo in mobilità. Se ve lo dimenticate a casa non potrete farvi nemmeno una ricarica. Che io sappia esistono 3 tipologie di token:

  1. Token pre-stampato ( quello di webank)
  2. Token fisico elettronico
  3. Token virtuale ( mobile app )

Il token pre-stampato è decisamente quello meno sicuro e meno comodo tra tutti. Infatti, se un malintenzionato, riesce a fare una foto al vostro token pre-stampato (ammesso che sia in possesso anche di : userid, password, data di nascita e altre informazioni personali) allora avrà pieno accesso al vostro conto.

C’è comunque da dire che webank permette di configurare degli alert via mail o sms e quindi sarete notificati ogni volta che farete l’accesso al vostro pannello webank via mail. Questo è sicuramente importante.

Assistenza clienti

Se avete un problema con la vostra banca fisica, vi vestite, prendete la macchina e andate in filiale. Con WeBank, come tutte le altre banche online il tutto è completamente diverso. Se da una parte abbiamo la comodità di poter contattare la banca seduti comodamente in pigiama davanti al pc, dall’altra, per alcune questioni, potreste preferire parlarne a quatr’occhi.

Quest’aspetto non è necessariamente un lato negativo della banca in se (tutte le banche online sono così) e credo che per la generazione di giovani questo sia più un lato positivo che negativo.

Versamento assegni e contante con webank

Ogni banca online ha questo problema. Con webank per depositare un assegno o soldi contanti, è necessario recarsi presso agenzie del gruppo Bipiemme. Essendo questo gruppo parecchio grande è molto probabile che nella vostra città sia disponibile almeno una banca facente parte del gruppo.

Se proprio non fosse possibile per voi recarvi su una banca del gruppo, allora potrete comunque andare in una qualsiasi banca compilando un modulo presente nel sito webank. Tuttavia, con quest’ ultima modalità avrete delle commissioni da pagare che varieranno da banca a banca

Ritiro contanti oltre i 2500€

Se aveste necessità di ritirare del contante sopra i 2500€ dovrete prenotare un ritiro presso una banca vicino a voi del gruppo bipiemme. Considerate che per legge, non è piu possibile fare pagamenti superiori a 999€ in contanti. Per rendervi l’idea negli ultimi 5 anni non mi è mai sucesso di fare quest’operazione.

Opinioni positive webank

La comodità

Ormai tutte le banche hanno un home-banking. WeBank però fornisce uno dei servizi completi e facili da usare che io conosca.

Possibilità di personalizzare il menu

Potendo gestire praticamente tutto dal pannello home-banking di webank (come già detto sopra) ci sono molte categorie. Webank fornisce la possibilità di personalizzarvi un menu in modo da accedere alle vostre “aree più usate” velocemente senza dover navigare tra le varie categorie ogni volta.

Applicazione mobile

WeBank è una delle poche banche online italiane che fornisce un applicazione android (e credo anche iPhone) ben fatta dove avrete la possibilità di fare gran parte delle azioni che fate online come ad esempio: Bonifico, giroconto, bollettino, pagamento bollo auto, ricarica cellulare.

Inoltre avete la possibilità di bloccare le carte e ricevere gli ALERT direttamente sul vostro telefono in push. Questo significa che, ad esempio, potreste ricevere una notifica sul vostro cellulare.

La sicurezza

L’home banking di tutte le banche online è decisamente incentrato sulla sicurezza (a livello informatico). Con WeBank abbiamo la posisiblità di fare il doppio login (sola lettura e dispositivo), abbiamo 2 livelli di credenziali e la sessione scade automaticamente dopo 20 minuti. Questo significa che se dimenticate il pc acceso con il vostro home banking aperto, fermo restando che comunque dovrebbero aver accesso alle vostre password dispositive per fare qualsiasi cosa che possa danneggiarvi, automaticamente webank non permetterà alcun tipo di operazione dopo 20 minuti.

Gruppo Bipiemme

Webank è stata acquisita dal gruppo bipiemme ( Banca popolare milano ). Considerando il loro rendimento in borsa si direbbe che il gruppo è solido e gode di buona salute finanziaria. Tradotto in italiano, essendo BPM in buona salute finanziaria si può dormire certamente più tranquilli che con altre banche (anche dal nome più conosciuto)

Social care

Un altro aspetto positivo di webank (secondo la mia personalissima opinione) è il loro customer care tramite i social network. Infatti è possibile contattare webank anche tramite Twitter, Facebook o GooglePlus.

Il social customer service di webank sembra essere molto “social friendly” ed è molto probabile che vi risponderanno nel giro di pochi minuti.

E’ inoltre possibile aprire il conto con webank e ricevere 120€ di buono utilizzabile presso mediaworld. Per ottenere il buono è solamente necessario aprire il conto tramite questo link.

Discerning if the user is using your android app from a phone, tablet or even Google Tv.

24 Ago 12

At some point every Android developer will need to develop an app that works ( exploiting each device functionalities ) on both Phones and Tablets ( or even Google TV ).

At the very beginning the first question that pops up in the dev mind is ( at least this was the question that popped out in mine ):

Should I make a single app version that works on both android phones and tablets? Or should i leverage the Google Play Store console benefits and upload different version of the same app optimized per each device?

Lets figure it out using a PRO/CONS approach

Single App

PROs (against to the multiple Apps):

  • Less code to maintain — when making a modification to some device agnostic code you don’t need to replicate it anywhere
  • Much more scalable

CONs:

  • You’ll be required to handle all the logic that routes specific device activities.

Multiple App

PROs (against to the Single App approach):

  • All the routing staff is made upfront from the Google Play store + AndroidManifest filtering.

CONs:

  • More code to maintain  — Fixing a bug on some shared code will require you to make 2+ app updates.

In this post i’ll cover how to understand if the used device is a tablet, a phone or a google tv. This is mostly useful for the Single App approach ( but in some cases could be helpful for in the Multiple App ).

The goal (yes again) is to have some piece of code that will help you understand if the device is a phone, tablet or a google tv.

I started googling and I found a couple of valuable resources on stackoverflow which helped a bit. But I didn’t find a complete and elegant solutions in none of them so I started my own research.

I needed to find an open source app that fullfilled the above mentioned prerequisites. It was surprisingly simple since Google, each year, releases the source code of their Google IO app. ( which uses the single app approach ).

If you never used the app I can assure you it works on both tablet and phones.

Lets talk no more and get to the real juice: Google IO Sched uses a  class called UIUtils which provides some static methods. Among of them you’ll be able to find the following methods:

  • hasHoneycomb: which returns true if the device is “at least” honeycomb apis => ics returns true
  • isTablet(Context): which returns true if the device is recognized as a tablet
  • isHoneycombTablet(Context): which returns true if both isTablet(Context) and isHoneycomb() returns true.
  • isGoogleTV(Context): which returns true if the device is a GoogleTV

Now you’ll probably wondering why there are 2 methods in order to recognize if the device is a tablet or not. Well, the answer is simple: There are tablets out there that are pre-honeycomb so you won’t be able to use the (out of the stock) Fragment apis available since Honeycomb.

Here the source code of those methods:

Now lets use this goodness to make something real. Lets suppouse you’ve 2 activities:

  • MapActivity: which is the activity that will be used for phones and eventually google tv
  • MapMultiPaneActivity: which is the activity designed specifically for tablets.
You could use the approach shown in the code below that also exploits the Facade pattern:
Warning: none of the previous code is mine. Everything was taken from the source code of Google IO Sched. BTW, I hope you enjoyed my effort of making this easy to understand/use

Android – Validate an email inside an EditText ( and more )

26 Mag 12

Input validation could be very painful. Building forms, in every technology, is a boring and painful job.

Fortunately on the web many libraries have born in order to facilitate this task to web developers. In android there are, built-in, some best practices you can use to facilitate the job but you’ll always have to take care about:

  • in-depth data validation
  • mandatory fields check
  • error presentation

Bored about giving birth another painful form I decided to write an opensource library that does almost everything for me. The library is called FormEditText and you’ll be able to browse/download the sourcecode here in github.

The basic usage of the library will allow the developer to get an edit text validated through xml attributes.

In this snippet of xml code we have a lot of good tech ( both from Android and my library ):

  • line #3:  we define a new namespace. You’ll need to modify the package name ( com.andreabaccega.edittextformexample in the code ) with yours
  • line #9: we provide an hint for the user so that he’ll know what he should write inside the field
  • line #10: we provide a value for the stock android:inputType attribute.
  • line #12: we tell the library that the field should be a valid email address

The last thing we’ll need to do is to ask the library to check the edittext validity:

This piece of code, performed when the user clicks the “submit” button, will ask the library to validate the content. Here two things could happen:

  1. the input is valid: in this case the library will just return true ( obviously )
  2. the input is not valid: in this case the library will return false and will set an error message that will look like the image on the top of the page.

When in the first case the library won’t do anything except returing “true” on line #3 of the previous snippet.

Further readings:

I’ll suggest to take a look at the github project. If you want to try the library I also setted up an example app that you can download from the market.


sviluppatori android

Link AppBrain | Link Android Market

Introducing Flatterizor

09 Mag 12

Flatterizor is a PHP library developed in order to issue a very specific problem.

Sometimes you have a complex object and you need to store it into your database. Most cases the serialize function does work. Unfortunately sometimes it does not ( not because serialize is broken/bugged ).

The Library is useful only if the followings are true:

  • You want to store your object inside a database
  • Your object is not “Flat”  ( meaning you’ve at least a value in your object that is an array or an object itself )
  • You want to use your Database SQL to Search & filter objects with a particular value.

The last sentence is actually the most appealing. Lets take, for example, the following objects:

Read More

How to backup your web server data [rsnapshot + rsync + ssh]

23 Apr 12

You start doing some research about this topic when one of the following events occurs:

  • You lose your data
  • You start hosting third party data

Read More

Android: How to execute some code only on first time the application is launched

12 Apr 12

It happens you need to execute some piece of code only on the first time the user start using your app.

Lets say you want to show a quick tutorial to the user just once — Indeed, when the user open your app for the first time.

Well, an easy solution would be to use a SharedPreference to store the info we need to accomplish this “task”.

Below, a snippet with a simple method ( to be included inside your activity class ) that will “solve” the problem.

Lost password reset software design pattern

07 Apr 12

When you build a new Service-Website from scratch you’ll probably have to face with this. Passwords are the most sensitive data we have and your application should behave securely enough to maintain user’s data private!

Some time ago you it was a common pattern to store the user password as plain text ( or with some Symmetric-key algorithm ). This let the user to retrieve their password withouth setting a new one.

From this pattern a fork was born which required to answer a predefined question in order to make the application send the password back to the user.

It seems these patterns are not used anymore in favor of the actual one which involves a more structured application/user flow in order to let the user regain access to the application. I’m talking about password reset.

The new way

Read More