Personal resume – Infographic

Some days ago I decided I wanted to change the page containing my resume so it wasn’t a boring CV. I wanted to do a more visual resume taking advantage of the web platform. I’ve seen those webs in HTML5 that create a kind of animation while scrolling over the page: Android KitKat, Firefox OS, or Robby Leonardi resume. But I think they are not practical and you have to keep scrolling and scrolling. I wanted a simple design, at a glance. The solution was to create an infographic.

To create the infographic I used the online tool Piktochart . It was very easy and it really works very well. These are some of its features:

  • Free. You can create a whole infographic for free.
  • Possibility of become a PRO user to get more themes or to export the infographic to an image up to A4 resolution.
  • Choose a theme or a blank infographic. I created mine from a blank template.
  • Export to jpeg, png or export the HTML.
  • Upload your own images or use the images and icons provided by picktochart.
  • Add links to the elements of the infographic.

You can see my first approach as an image in pinterest here.

Read More

Giveaway Winners: Free copy of my book on Android Studio

The giveaway that was published here, has ended. The winners were generated automatically and I’ve already contact them to let them know about it.

Winners:
Sergio (entry #71)
Paul (entry #62)
Saravanan (entry #113)

I used an external tool, PromoSimple (promosimple.com) to register the entrants and their number of entries. The following screenshot shows the Manage Winners page in which you can generate a winner for each prize.

Manage winners

To generate a random number, you can use the external site of Random.org or the PromoSimple generator.

Generate winners randomly

Thanks to everyone who participated and shared it!

You can still buy it at several sites:

Android Studio Application Development

Read More

Win Free copy of my book on Android Studio

Readers would be pleased to know that I have teamed up with Packt Publishing  to organize a Giveaway of the Android Studio Application Development book.

And three lucky winners stand a chance to win ecopy of their new book. Keep reading to find out how you can be one of the Lucky Winners.

Overview

Android Studio Application Development

  • Install Android Studio and configure the Android Software Development Kit
  • Create your first project and explore its structure
  • Improve your productivity while programming, by getting the best from the code editor
  • Design the user interface and learn how to handle user events
  • Integrate the Google Play Services into your app
  • Test your app using the emulator and learn how to manage the virtual devices
  • Run and debug your app
  • Monitor your app whilst it is running and improve its performance
  • Build your app for release

How to Enter?

All you need to do is write your e-mail and name below. It’s that simple. Winners will be contacted by email, so be sure to use your real email address when you comment!

In the second step, you can get extra entries if:

  • You head on over to the book page (Android Studio Application Development) and look through the product description of the book and drop a line via the comments after sending your email, to let us know what interests you the most about this book.
  • You tweet about this giveaway.
  • You follow me on twitter.

Winners from the U.S. and Europe can either choose a physical copy of the book or the eBook. Users from other locales are limited to the eBook only.

Read More

(Private) Libraries in Android: Part III

In the first post about libraries in Android, I proposed two different solutions to share a project with resources but without sharing the source code:

In this post, I will show in detail the second one: to create the resources programmatically instead of using the XML files and export it to a JAR file. The steps are the following:

  1. Create a java project to add the code.
  2. Import the Android SDK into the java project.
  3. Create the resources programmatically.
  4. Export the java project to a .JAR file excluding the source code.
  5. Import the .JAR into the client project or add an intermediate Android Library Project.

Private library process

Let’s show a short example, the same example used in the part II. Suppose we want to create a library to provide a log-in screen to authenticate users in our system. We want to keep the code that connects to our servers and authenticates the users in private. We also want to provide the user interface in order to maintain our own corporative design and now we will keep that user interface in private too.

1. Create the Java project

Create a Java project and create a package and a class in it. Let’s name the class “Authenticator”, a final class with one static method. This class has the code of our authentication system.

Java project structure

Add the method code:

package belencruz;

public final class Authenticator {
   /**
    * Method to authenticate users.
    * @param user User name
    * @param pass User password
    * @return true if login is correct
   */
   public static boolean authenticate (String user, String pass) {
      // Connect to my server to authenticate

      // For this example:
      if(user.equals("Belen") && pass.equals("belen"))
         return true;
      return false;
   }
}

2. Import the Android Jar

Add the Android library to the project as you would do to add any external library .jar. You will find de android.jar file in the Android installation from your system, for example in a path like /androidSDK/platforms/android-18/android.jar.

android.jar in project

3. Create the resources

We are creating the resources programmatically, that’s why we added the android.jar in the previous step. Create a new final class named as “LayoutCreator”. In this class we add the method that will contain the code to create the login layout. We can add different methods for different views. Additionally, we will have to create the R.java class to store the IDs of the layout components.

Library structure

package belencruz;

public final class LayoutCreator {
  /**
    * Method to create the login view.
    * @param context Activity that needs the view
    * @return login View
   */
   public static View createLoginLayout(final Activity context) {
      LinearLayout loginLayout = new LinearLayout(context);
      loginLayout.setOrientation(LinearLayout.VERTICAL);

      ...

      return loginLayout;
}

Now just the code to create the components inside the layout is left. To create the text inputs, add the following code:

// Edit Text User
EditText userInput = new EditText(context);
userInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
userInput.setId(R.id.userInput);
userInput.setHint("e-mail");

// Edit Text Password
EditText passwordInput = new EditText(context);
passwordInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
passwordInput.setId(R.id.passwordInput);
passwordInput.setHint("password");

loginLayout.addView(userInput);
loginLayout.addView(passwordInput);

Lines 13 and 14 add the components to the login layout. To create the accept button add this code:

// Button Accept
Button loginButton = new Button(context);
loginButton.setText("Accept");
loginButton.setId(R.id.loginButton);

loginLayout.addView(loginButton);

And finally we need to handle the button event. We get the user credentials from the layout and start the authentication process. Since the login is a costly process, we execute it in a new thread. To simplify the example, I used a Runnable object, a better way would have been the use of an AsyncTask.

loginButton.setOnClickListener(new OnClickListener() {
   public void onClick(View v) {
      new Thread(new Runnable() {
         public void run() {
            TextView user = (TextView) context.findViewById(R.id.userInput);
            TextView password = (TextView) context.findViewById(R.id.passwordInput);

            Authenticator.authenticate(
               user.getText().toString(),
               password.getText().toString());
         }
      }).start();
   }
});

Export the project to a .JAR file excluding the source code. If you are using eclipse, then in the export dialog, just check the “Export generated class files and resources” option, but don’t check the option “Export Java source files and resources“.

4. Create an Android Library Project

Create a new Android project and check it as a library project.

Library project check

Import our library .JAR from the previous step.

Open the main activity and in the onCreate method we need to change the view that is loaded from this activity. Change the call to the setContentView method to this:

setContentView(LayoutCreator.createLoginLayout(this));

5. Create the client Android project

Create a new Android project, not library this time. Add the library project to this new one.

Add the library project

In the main layout of this project, add a login button. When the user clicks the button, the user interface will switch to the login layout from our library. So, in the main activity, add the following code in the handler method of the login button:

public void onLoginClick(View v){
   Intent i = new Intent(this,
      com.belencruz.mylibrary.MainActivity.class);
   startActivity(i);
}

Finally, don’t forget to declare the library activity in the manifest file of the client project. Open the AndroidManifest.xml from the client project and inside the application tag, add the following declaration:

<activity
   android:name="com.belencruz.mylibrary.MainActivity">
</activity>

Read More

Android Studio Application Development

Android Studio Application Development is the book I’ve been working on during this last summer. Last week was published by Packt Publishing. It is available at several sites:

Book coverBook backside

Mobile apps have become extremely popular over the last few years and offer a great opportunity for developers. Android is now one of the most popular mobile systems in the world. The new Android Studio IDE has introduced a specialized development environment, welcomed by the emerging Android community, which is perfect for the development of apps.
“Android Studio Application Development” is a practical guide that will show you how to develop and build Android apps using this new, integrated development environment. Following a tutorial approach, this book will progress from the basics features up until the steps to build for release, using real world examples. This book is a must have for every Android app developer evangelist.

Our book explores the Android Studio development environment in-depth, taking you through the necessary steps to create an app, test it, and prepare it for release. First, you will learn how to use the code editor in order to increase your productivity, and to easily create the screens of your app. Then, this book will show you how to debug your app and examine its performance using the most important additional tools within Android Studio: Android SDK tools. We will also take a look at the existing Google Play Services and how they can be integrated into your app.

Finally, it is important for a developer to be able to search for any help they might need. This book provides a vast help section which covers online documentation, updates, and FAQs.

Sample Chapter

You can download a sample chapter here.

Read More

(Private) Libraries in Android. Part II

In the first post about libraries in Android, I proposed two different solutions to share a project with resources but without sharing the source code:

In this post, I will show in detail the first one: creating a Library Project to include the resources, but including the source code using a JAR file. The steps are the following:

  1. Create a java project to add just the code, not resources.
  2. Export the java project to a JAR file excluding the source code.
  3. Create a Library Project to include the resources.
  4. Add to the Library Project the previous created JAR.
  5. The client project will import the Library Project which contains the resources and the JAR file.

Private library process

Let’s show a short example. Suppose we want to create a library to provide a log-in screen to authenticate users in our system. We want to keep the code that connects to our servers and authenticates the users in private. We also want to provide the user interface in order to maintain our own corporative design.

1. Create the Java project

Create a Java project and create a package and a class in it. Let’s name the class “Authenticator”, a final class with one static method.

Java project structure

Add the method code:

package belencruz;

public final class Authenticator {
   /**
    * Method to authenticate users.
    * @param user User name
    * @param pass User password
    * @return true if login is correct
   */
   public static boolean authenticate (String user, String pass) {
      // Connect to my server to authenticate

      // For this example:
      if(user.equals("Belen") && pass.equals("belen"))
         return true;
      return false;
   }
}

Export the project to a .JAR file excluding the source code. If you are using eclipse, then in the export dialog, just check the “Export generated class files and resources” option, but don’t check the option “Export Java source files and resources“.

2. Create an Android Library Project

Create a new Android project and check it as a library project.

Library project check

Import our library .JAR from the previous step. The project structure now looks like this:

Library project structure

Open the main layout and create a simple login layout. To avoid conflicts between names, it is a good idea to change the name of this layout file, for example, to “library_activity_main.xml”.

Login layout

Now open the main activity and add the method that will be run when the user clicks on the Accept button. Add the code to call the method of our .JAR:

import belencruz.Authenticator;
...

/**
* When user clicks the Accept button. Login.
* @param v
*/
public void onAcceptClick(View v) {
   final EditText et_user = (EditText) findViewById(R.id.editText_user);
   final EditText et_pass = (EditText) findViewById(R.id.editText_pass);

   new Thread(new Runnable() {
      public void run() {
         Authenticator.authenticate(
            et_user.getText().toString(),
            et_pass.getText().toString());
      }
   }).start();
}

In this method, we get the user credentials from the layout and start the authentication process. Since the login is a costly process, we execute it in a new thread. To simplify the example, I used a Runnable object, a better way would have been the use of an AsyncTask.

The project library is now ready to be imported in other Android projects.

3. Create the client Android project

Create a new Android project, not library this time. Add the library project to this new one.

Add the library project

In the main layout of this project, add a login button. When the user clicks the button, the user interface will switch to the login layout from our library. So, in the main activity, add the following code in the handler method of the login button:

public void onLoginClick(View v){
   Intent i = new Intent(this,
      com.belencruz.mylibrary.MainActivity.class);
   startActivity(i);
}

Finally, don’t forget to declare the library activity in the manifest file of the client project. Open the AndroidManifest.xml from the client project and inside the application tag, add the following declaration:

<activity
   android:name="com.belencruz.mylibrary.MainActivity">
</activity>

Read More

Libraries in Android. Part I

Libraries are one of the best mechanisms to get reusable code. Knowing how to create libraries is a basic step when we have any common functionality for several apps or we want to share it with other developers. The two simplest ways to share code in Android are:

  • Android library projects. We can get any standard Android project to act as a library by activating this property. The library can be imported into any project that needs to use it. The library project is distributed with its source code and resources. To read a complete description of library projects, see the official documentation here.
  • JAR files. A .jar file contains the compiled classes. The source code can be included in it or not. We can’t share Android resources using a .jar file, just code classes.

The decision to choose between one of them depends on our requirements. Do we want to share xml resources? Do we mind sharing the source code?
Library types

How can we share a project with resources but not to share the source code? As the Android documentation states,

A library cannot be distributed as a binary file (such as a JAR file). This will be added in a future version of the SDK Tools.

I propose two solutions (surely there are more of them):

  • Create a Library Project to include the resources, but include the source code using a JAR file.
  • Create the resources programmatically instead of using the XML files and export it to a JAR file.

These proposed solutions will be shown in detail in the next posts about this topic:

Read More

Passbook: Type ID and certificate

Related posts about Passbook:


In order to create passes and allow them to be recognized by Passbook, they have to be signed with a valid certificate. The certificate is associated to a specific type of pass, so we need to create a Pass Type ID and a certificate for each kind of pass we want to support.

To create a Pass Type ID, log in into your developer account, navigate to your member center and to the Certificates, Identifiers & Profiles page. In the identifiers section, select the Pass Type IDs option. From this page the passbook Type IDs are listed and we can edit them, delete them or create a new one. Click on the plus icon button to create a new ID. Type a description and type the ID which has to start with the “pass.” string.

Register iOS Pass Type ID

Follow the next steps and the ID registration will be completed. The new ID should appear in the Pass Type IDs list.

To create the Pass Type ID Certificate, open the Production page from the Certificates section and click on the plus icon button to create a new one. Check the Pass Type ID Certificate option and click on the Continue button. In the next page we have to select the ID created before. Click on the Continue button.

iOS certificate of the Pass ID

Finally we have to upload our Certificate Signing Request file (.certSigningRequest). This request file can be obtained from the Keychain of a MacOS computer, but probably you already generated it when you created your app or created other certificates. Upload this request file, click on the Generate button and then we willl be able to download the certificate by clicking the Download button. The downloaded certificate is a .cer file.

Download Pass certificate

Read More

Best apps to learn a language

When we want to learn a new language, it is a common thing to search for our own resources. These resources can be books or online sites with lessons, podcasts and exercises. A good alternative is to use mobile applications, even better if you can use a tablet.

Currently I am learning French and I am using mobile applications myself, so I have written a post about the ones I consider the most useful.

1. Duolingo

iPhone Screenshot 2iPhone Screenshot 3

iPhone Screenshot 4

Web page http://www.duolingo.com/
Web version Yes
Devices iPhone/iPad, Android
Languages Spanish, French, Italian, Portuguese, German, English
Price Free
Internet connection Necessary to open a lesson different from your current level

Being totally free, this app provides a variety of exercises that work on all the necessary areas: writing, listening, speaking… It is good for learning vocabulary and grammar, because all the exercises are based on sentences, so both of them are presented together, making it easy to learn.

What I like the most is the translation and listening exercises, in which you have to write whole sentences by translating the original or listening to it. This is more difficult and instructive than just choosing the correct answer from some possible options, like most of apps do.

Your progress is displayed as a nice hierarchy of levels and when it’s been a long time since you last used the app, you will have to do some refresher exercises.

2. MindSnacks

Captura de pantalla del iPhone 1

Captura de pantalla del iPhone 2

Captura de pantalla del iPhone 5

Web page http://www.mindsnacks.com/
Web version No
Devices iPhone/iPad
Languages An app for each language: Spanish, French, Italian, Portuguese, German, Chinese, Japanese.
Price Free but in-app costs to get all the lessons: 4.49€
Internet connection Not necessary

This app is perfect to learn vocabulary. By playing games we can study the vocabulary and have fun with it. To make it more addictive, there are also challenges to get extra points and level up. A disadvantage is not having an app for Android.

What I like the most is that you can play the games using the vocabulary from all the lessons (or just some of them) at the same time, so they are not limited to a specific level, like most of apps do. This functionality is the best way to refresh the vocabulary.

3. Busuu

iPhone Screenshot 3

iPhone Screenshot 4

iPhone Screenshot 2

Web page http://www.busuu.com
Web version Yes
Devices iPhone/iPad, Android
Languages An app for each language: Spanish, French, Italian, Portuguese, German, English, Chinese, Japanese, Russian, Polish, Turkish
Price Free but in-app costs to get all the levels: 4.49€ each level. Full course: 14.99€
Internet connection Necessary to do some types of exercises

This app is the most expensive but it have a lot of different lessons with different types of exercises. In comparation to the other two apps, this app is not so good at making you memorize the vocabulary. The exercises consist on choosing the correct option from the proposed ones. There is not listening exercises and the writing exercises are corrected by the people from the bussu community.

What I like the most is the text comprehension exercise in which a text is displayed, audio included, and we have to answer questions about it. The other advantage of this app is that the language offer is wider.

Read More