Hacker Rank’s 30 days of code challenge

For people who are new to programming to those who want to sharpen their coding skills, Hacker Rank has been running the 30 days of code challenge.

Every day a new challenge is posted ranging from introductory topics to mid-level challenges. There is also a new video tutorial every day related to the topic of the challenge.

Hacker Rank 30 days of code challenge

It is a great way to practice problem solving skills and it accepts solutions on several programming languages, such as Java, C, C++, Clojure, D, Fortran, Go, Perl, Swift, Objective-C, Python, among others (you can even code on the Brainfuck language!).

You can access the challenges here: 30-days-of-code challenges

I am posting the Java solutions on my Github account, so if you want to check them, access them here: 30-days-of-code solutions

Google I/O 2016 announced

This week Sundar Pichai, Google CEO, announced in a tweet that Google I/O 2016 has been scheduled for May 18th through the 20th. It will take place on Mountain View’s Shoreline Ampitheatre, back where the conference first stated.

Google I:O 2016

Android N,  updates to Project Tango, Google Cars, Android Wear, Chrome OS, Project Ara and a possible second-generation model of Google Glass are expected!

Google I/O 2015 announced

One of the most anticipated events for Android developers, Google I/O, will occur on May 28-29 and will take place at the Moscone Center West in San Francisco.

Registration for tickets will open on March 17th at 9:00 a.m. PDT and will run for two days. Just like last year, Google will pick the people who will “receive the opportunity to purchase one ticket” at random.

Google I/O

It will also be possible to watch the keynote and select sessions in real-time, from a laptop or mobile device.
More information can be found on the official website: Google I/O 2015

Unit testing support on Android Studio!

With the release of Android Studio 1.1 Beta 4 to the beta channel it now supports unit testing.

Unity testing
Unity testing

The first step to use it is to update your build.gradle file and add the following dependencies:

dependencies {
  testCompile 'junit:junit:4.12'
  testCompile 'org.mockito:mockito-core:1.9.5'
}

Android Studio also needs to be set, as explained in details here.

This is a great addition to Android Studio, improving an already awesome IDE for development and allowing software engineers to become more productive and efficient.

Updating Android properties of all modules from root project

Today at work a friend gave me a very good tip to update properties of all modules of my project from the main project.

My project has 6 modules and a main (root) project. What I used to do when releasing a new version of an app, or updating a property such as build tools, was to go to each module and manually update these properties on their build.gradle file:
apply plugin: 'com.android.application'

android {
compileSdkVersion 20
buildToolsVersion '21.1.1'
    
    defaultConfig {
       versionCode 20
       versionName '20.1.5'
       minSdkVersion 10
       targetSdkVersion 21
    }
}

That meant updating 6 different files (or even more if any of these properties were set on AndroidManifest).

The best approach for this scenario is to have all these properties set on your main project, adding a configuration like this in its build.gradle file:
ext {
    compileSdkVersion = 20
    buildToolsVersion = '21.1.1'


    versionCode = 20
    versionName = '20.1.5'


    minSdkVersion = 10
    targetSdkVersion = 21
}
And on your modules’ build.gradle files you add these configurations:
apply plugin: 'com.android.application'

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        versionCode rootProject.ext.versionCode
        versionName rootProject.ext.versionName
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
    }
}

This way your modules will reference your main project and whenever you need to update one of these properties you will just need to modify one file, improving your project’s maintainability.

Also, ext.* properties are dynamically created so you can add new properties of any type depending on your needs.

That means that you can configure other properties such as sourceCompatibility and targetCompatibility.

Instead of adding them to every module with:
android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}
Add them to the other properties in your main project:
ext {
    compileSdkVersion = 20
    buildToolsVersion = '21.1.1'


    versionCode = 20
    versionName = '20.1.5'


    minSdkVersion = 10
    targetSdkVersion = 21

    sourceCompatibility = JavaVersion.VERSION_1_7
    targetCompatibility = JavaVersion.VERSION_1_7
}
And reference them in the other modules, just like the other properties:
android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        versionCode rootProject.ext.versionCode
        versionName rootProject.ext.versionName
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
    }

    compileOptions {
        sourceCompatibility rootProject.ext.sourceCompatibility
        targetCompatibility rootProject.ext.targetCompatibility
    }

}

Android – Managing the activity lifecycle

Today I will talk about a very important topic in Android mobile apps development: managing the lifecycle of an activity.

When someone navigates through an app the Android system calls a series of lifecycle methods on activities in which developers can set up the user interface and other components and actions. One example is when an user performs an action that starts another activity. When that happens the system calls another set of lifecycle methods on the activity as it moves into the background (where the activity is no longer visible).

The following picture (from Android developer training website, a great place to learn things about Android) shows a simplified illustration of the Activity lifecycle.

Activity lifecycle
Activity lifecycle

When the user first opens an activity the onCreate() callback is called. This method should implement basic application startup logic that should happen only once for the entire life of the activity, like the definition of the user interface.

Once onCreate() finishes execution, the system calls the onStart() and onResume() methods in quick succession. The activity never reside in the Created or Started states. The onStart() method is a good place to verify that required system features are enabled. The onResume() method should perform any other initializations that must occur each time the activity enters the Resumed state (such as initialize components only used while the activity has user focus).

The system calls the onPause() method when the activity is still partially visible and most often is an indication that the user is leaving the activity and it will soon enter the Stopped state. The onPause() callback should be used to stop animations or other ongoing actions that could consume CPU, commit the necessary unsaved changes and release system resources.

The onStop() method is called when the activity is no longer visible and should be used to release almost all resources that aren’t needed while the user is not using it.

The last last callback, onDestroy() is called by the system as the final signal that the activity instance is being completely removed from the system memory. If the app decides to implement this method it can be used to kill background threads created during onCreate() or other long-running resources that could potentially leak memory.

This explanation was a summary of the main points related to the activity lifecycle. There is a lot more involved, especially if you decide to use fragments in your activities. For more information, check the Android developers training website.

The highlights in mobile news this week:

Techcrunch wrote an Android 5.0 Lollipop review: Tablet Edition

The Android official blog wrote about how to design the perfect Lollipop

Google calendar is smarter and prettier

Facebook is changing election day

Dropbox’s Drew Houston responded Snowden’s privacy criticism

Android developers can now publish apps for Android TV on Google Play

Android 5.0 Lollipop

Android 5.0 Lollipop was revealed on June 25, 2014 during Google I/O and will be made available in November 2014 for select devices. Originally called Android L, we found out its official name in a Google announcement made on October 15, 2014.

In this post I will discuss what are some of its main new features and what devices are going to support it.

Android-5-lollipop-1

New features

Notifications

There are many new features in notifications. Users can now view and respond to messages directly from their lock screen. There is now a Priority mode that can be turned on so only certain people and notifications can get through. It is possible to hide sensitive content and prioritize or turn off the app’s notifications entirely. There is also a more intelligent ranking of notifications based on who they’re from and the type of communication.

Runtime and performance

It now uses ART, an entirely new Android runtime, that improves application performance and responsiveness, allowing up to 4x performance improvements and smoother UI for complex, visually rich applications. There is now a support for 64 bit devices that brings desktop class CPUs to Android.

Security

The devices running Android 5.0 will come with encryption automatically turned on and will have the option of using Android Smart Lock to secure the phone or tablet by pairing it with a trusted device.

Media

There is now lower latency audio input, improving the user experience while listening to audio, multi-channel audio stream mixing, allowing applications to mix up to eight channels and also a USB Audio support. For the photographers there are features like capturing full resolution frames around 30 fps and capturing metadata such as noise models and optical information.

Battery

There is now a battery saver feature which extends device use by up to 90 minutes and information about estimated time left to fully charge the device and estimated time left on the device before it is necessary to charge again.

Android Lollipop is going to be available in over 68 different languages. Users can use the “OK Google” voice command to talk to Google on the go and get quick answers, send a text or get directions.

Android-Lollipop

Devices

The following devices will have Android Lollipop:

Nexus

Nexus 4, 5, 7 (2012), 7 (2013), 10 and Google Play Edition devices

Motorola

Moto X (1st and 2nd generations)
Moto G(1st and 2nd generations)
Moto G 4G
Moto E
Droid Ultra, Droid Maxx e Droid Mini

Sony

Xperia Z, Xperia ZL, Xperia ZR, Xperia Tablet Z, Xperia Z1, Xperia Z1S, Xperia Z Ultra, Xperia Z1 Compact, Xperia Z2, Xperia Z2 Tablet, Xperia Z3, Xperia Z3v, Xperia Z3 Compact and Xperia Z3 Tablet Compact

Asus

Zenfone 5, Zenfone 6

HTC

HTC One (M8) and HTC One (M7)

No official announcement was made by Samsung or LG, but a schedule was leaked that may contain information about which of their devices will receive the update.

If you are lucky enough to have one of these devices, you will soon be enjoying this new amazing version of Android!

The highlights in mobile news this week:

Google’s LEGO-Style Phone, Project Ara update

Google Fit is officially available

Facebook keeps top spot for social referrals, Twitter drops further behind Pinterest

How the Apple Watch interface looks like on an iPhone

Movie comparison

I recently rewatched two movies: a mainstream one reflecting solitude, Cast Away, and a technology overload movie, The Social Network.

I noticed that, even though they seem very different, they cover similar concepts and show the importance of different things in our lives. I will briefly describe them here and write about what lessons we can learn when we compare both movies.

Cast Away is a 2000 adventure drama film directed and produced by Robert Zemeckis that tells the story of Chuck Noland (Tom Hanks) as a FedEx employee. Chuck is a time-obsessed systems analyst that is constantly busy. In one of his job assignments Chuck is asked to go to Malaysia but, after a violent storm, his airplane crashes into the Pacific Ocean. He spends the rest of the movie trying to survive on the island using remnants of his plane’s cargo. After four years cast away Chuck becomes adept at spearing fish and making fires. He also becomes very close friends with Wilson, his volleyball friend. After managing to get back to civilisation, he realizes that a lot has changed and has to decide how to move on with his life. The film was a critical and commercial success.

The Social Network is a 2010 drama film directed by David Fincher and written by Aaron Sorkin. It tells the story of how Facebook was founded: After agreeing to work on Cameron and Tyler Winklevoss’ idea for a social network for Harvard students aimed at dating, Mark Zuckerberg changed his mind. He and his friend, Eduardo Saverin, started working on Thefacebook, an online social networking website that would be exclusive to Ivy League students. They met with Napster co-founder Sean Parker, and later moved to Palo Alto. After unknowingly signing a contract that reduced his share of Facebook from 34% to 0.03%, Saverin sued Mark. Zuckerberg was also sued by the Winklevoss brothers, who claimed that he had stolen their idea for the social network. The film was a huge success and was awarded 3 oscars.

At first sight it seems like the movies aren’t similar at all. But after thinking about them, I believe that they both talk about connection between people. When Chuck Noland was isolated in an island he became friends with a volleyball, Wilson, and regularly talked to it. The Social Network discusses the idea of creating a network where people can add their friends and talk to them by sending messages. The network eventually becomes a huge success, further proving how people want to be connected. The main thing I learned from these movies is that being connected to other people is paramount, but it is also important to have moments of isolation so that people can also connect with themselves.

The highlights in mobile news this week:

Apple pay works

Life360 Acquires Two-Month-Old HelloWorld

Google Acquires Firebase To Help Developers Build Better Real-Time Apps

Hands-on with Nexus 6

Hands-on with Nexus 9

How to create a great customer experience

Companies already know that acquiring new customers is considerably more expensive than keeping the ones they already have. Satisfied customers are the ones that stick around and, consequently, use and buy more products and promote the brand to other people.

There is also a whole industry based around maximizing customer experience at “all points of contact” with a company, making this a very important topic for companies that want to succeed and have a competitive advantage. In this post I will talk about the three main characteristics that make a great customer experience and give some examples of companies that are doing a good job.

Rule number 1: Build strong relationships

A company that knows what its customers want can build a strong relationship with them. By not only giving customers what they are looking for, but also exceeding their expectations, companies can differentiate themselves. When that happens the satisfied customers return and use more of the companies’ services instead of its competitors. It is important to always stay in touch with customers, not only at the purchase time, but also on other special dates, like sending them an e-mail on their birthday to maintain a good relationship.

Rule number 2: Start at the top

The customer experience has to start with the CEO. The CEO and the board of directors need to keep customer experience as one of the companies priorities so that the other employees will think the same way and follow the example.

A good way of doing that is to have specific goals related to customer experience and also a team focused on listening to customers complaints/feedback and acting quickly to answer them. Another effective idea is to ask the team focused on customer experience to make regular presentations to the other teams, so that all employees can know what the customers are saying and suggesting.

Rule number 3: Use metrics

You need a way to measure whether your customers are happy or not. This way it is possible to see if recent changes in the company or in its products are aligned with customers needs. Surveys are a great way to do that, always combining closed-ended (to have more quantifiable metrics) and open-ended (to allow customers to freely express their opinions) questions.

Some companies are constantly trying to improve their customers experience, like Google, that used an approach of answering customer questions one on one, at the time they were being asked and also included a video calling support option to them. This helped the company to improve its customer satisfaction scores from 44% to 90%.

Zappos aims to deliver to its customers a wow experience by allowing them to easily customize Zappos seemingly unlimited options into exactly what each of them needs and wants.

Apple is very famous for its customer service and, according to Carmine Gallo, author of The Apple Experience, there are 5 Steps of Service that every Apple Store staff member need to follow:

A = Approach Customers with a personalized, warm welcome

P = Probe politely to understand the customer’s needs

P = Present a solution for the customer to take home today

L = Listen for and resolve any issues or concerns

E = End with a fond farewell and an invitation to return

Also, remember rule #2 above? This video is a great example of it:

Another company with a great customer experience is Amazon. Always trying to quickly answer its customers, Amazon also innovates on the customer interaction, like this recent case in which an Amazon employee role played as superhero Thor while dealing with a customer.

Companies that are not currently focusing on their customers experience should begin to do it as soon as possible in order to get more loyal customers while also improving their products and services.

The highlights in mobile news this week:

Breaking news: Android 5.0, Nexus 6 and Nexus 9 were announced today in Android Official Blog

Boston startup scene is growing stronger

Facebook stickers are now available in comments on timelines, groups and events