Blog Archives

Android at #io16

(As usually…) It has been a while since my last blog post 🙂

This time I’m coming back just to tell you briefly about Google I/O 2016!
Last time it was back in 2013 when I went with my friend Massimo and since then a lot of things have changed. The Android platform got a lot more mature and my impression is that Google started to focus more on simplifying the developer life while still gaining a lot of new data.

I’m not gonna talk about VR, Artificial Intelligence and Machine Learning. These are really cool technologies but my developer heart still belongs to an Android made of custom UIs, Content Providers, messy fragments, multi-threading, memory constraints,… and… why not… Android Studio!

It’s kind of funny because back in 2013 when Tor Norbye and Xavier Ducrohet announced Android Studio starting to ditch support for Eclipse, I was a bit upset. After few months, I started to appreciate IntelliJ and all the efforts that the Android Developer Tools Team made in order to have a first class Android IDE integration/experience.

…but this is the past!!! Without forgetting about being dwarfs standing on the giants shoulders, let’s focus on the present and what’s ahead of us! 🙂

This Google I/O 2016 came with a lot of news:

  • Android N will support native Multi Window with Drag&Drop capabilities.
  • ConstraintLayout: not a RelativeLayout, not a FrameLayout, not a LinearLayout, not a PercentageBlaBlaLayout,… but a completely new ViewGroup that comes with a full integration in a new layout editor for Android Studio. The power of this new tools is based on the promises of flattening drastically the View hierarchy creating constrains between Views and parents! 🙂
  • Java8 support + Jack Compiler
  • An APK analyzer to inspect generated APKs and help you try to remove un-necessary and/or un-optimized resources
  • Instant Apps is a new feature that will allow you to modularize more your application allowing the user to download just a single use case of your app, without having to install a full APK. Even if it might look a bit strange, this tool could be really handy when it comes to introduce your service to new users, engaging them little by little.
  • Android Wear 2.0: even if it comes as a preview, it will have a new enhanced user interaction and more immersive experiences.
    • Watch Faces will support more than just time and battery info. There will be a chance to support more complicated(complications) data that will provide useful info to the user.
    • Notification will come with a new interaction style and paradigm.
  • Firebase: this is kind of hard to describe. The most simplest description that comes in my mind is “A magic box that contains a lot of tools to help you build better apps.  All these kind of little things those are taking a lot of time when developing new features in your apps will become definitely a lot easier. A/B testing, analytics, syncing, login, GCM,… have been bundled and connected(not all of them) togheter into Firebase, giving you a simple way to check and maintain them.

…there is definitely a lot more and you can check it out on the Google I/O 2016 Youtube channel!

I hope you’re gonna enjoy some of the pics I took over there 🙂

This slideshow requires JavaScript.

Cheers,
Simone

P.S.:
..if you live in UK, have a long weekend! 🙂

Colonizing Wearables (part 3)

In “Landing on Wearables” we have approached wearables devices extending our existing app’s notifications and explaining briefly how to bind them to our development machine for debugging purposes. Now it is time to study more in deep what we can achieve directly on a device running Android Wear, understanding the constraints and the possibilities that the platform introduces. We will continue to keep as reference the Books application previously developed and we will try to create an Android Wear module.

Read the rest of this entry

Landing on Wearables (part 2)

In “Introduction to Wearables” we had a look at some of the concepts those are the foundations of Android Wear. In this part we are going to skip completely any considerations on that and we’ll have a look at how things work underneath. In particular, we’ll have a look at how to extend existing application’s notifications and how to debug on wearables(this second part will be used for the following tutorials). In order to achieve this, we’ll start with a sample application that runs just on a handheld device and we’ll try step by step to extend it, trying to create a beautiful user experience even on a device running Android Wear. Read the rest of this entry

Introduction to Wearables (part 1)

Wearable devices are definitely one of the most exciting and coolest technologies of 2014 along with drones and smart cars. Hardware producers, software companies and even start-ups are pushing the boundaries beyond what is just being on a handheld device, struggling to open new challenges and attract new customers. Something similar has been already seen when smartphones were just at the beginning of their appearance, but this time the purposes and targets of this technology are a little bit different. It is not just a matter of keeping the user connected with the World outside but it’s more about offering him new services, getting more from/into his life. Sensors can collect data about user activities (heart rate, pedometer, burn calories, sleep hours…) allowing to know more from the user’s context and his behaviors. Embedding them on wearable devices(smartwatches, rings, betls,…) can grant almost a 24 hours coverage, attracting the user to use something that he is already used to wear but with more functionalities and fancier. Read the rest of this entry

A new #Android App for @MailOnline

In the last few months the MailOnline mobile team has completely rewritten from the scratch their Android application. Getting rid of the old code, we came across to a lot of iterations and problems those have forced us to re-think the entire background synchronization and the resource management. As one of the Android developer who has developed this version, I’m very proud to say that this version is definitely better, faster and smoother than the prior one.

This slideshow requires JavaScript.

The main features, improvements and changes that you’ll certainly noticed from the screenshots are:

  • Load more articles when you reach the bottom of a channel
  • Swipe down to sync news in the channels page (with progress percentage)
  • Swipe between different channels
  • A new drawer menu that will appear swiping from the left edge of your screen (enable in settings)
  • Share and comments feedback inside the articles
  • Shortcuts from article to main channels
  • Filters on data and image sync
  • Different priority and order for channels (based on your preferences)
  • Enriched FAQs screens

There’s still always something new to do and to improve but this can be consider a really good app that will allow thousands and thousands of people to read their favorite news paper.

Thanks,
Simone

Algorithms are fu**ing awesome!

If you have a quick look on Wikipedia you’ll find out that algorithms are procedures used to solve calculations and to process data.

When I was in university, one of my teacher has defined them like a receipt. Imagine that you have got dozens of ingredients. You have to mix them in order to obtain something that’s really tasty and that can be considered eatable.

From a certain point of view that’s true. Isn’t it? 🙂

One thing that takes a little bit of attention is the fact that the ingredients have to be selected and manipulated following particular procedures otherwise you’ll obtain a food that it something “similar” to what you are expecting.

One week ago, I was reading a problem on Codility that at the beginning was appearing really… really… EASY PEASY!
That’s the greatest mistake that you can do! It doesn’t exist a problem that is simple… otherwise it’s not a problem 😉

After that assumption, I tried on my favorite editor to solve the problem and it “was failing some tests” (if it doesn’t cover any case it’s wrong).
I misunderstood the fact that my solution wasn’t considering entirely the input.

Hence I decided to focus on the velocity of the execution because maybe some loops + if statements were speed down the execution.
That’s another problem: don’t focus on velocity at the beginning. You’ll incur in a lot of mistakes and the problem will become more complex than expected.

At that point I decided to drink a huge cup of strong Italian coffee. “What am I doing?!?!? That’s not the way!”
This was not the idea that solves all your problems but a kind of ray that was saying me that I should start to think instead of trying a feasible solution .

At the end that’s the result:

Detected time complexity: O(N * M * log(M) + N * log(N))
Score: 100 of 100

…getting back to my teacher’s words, when you are sure that your solution works, you should start to think “Can I do something more?“.

Most of the time the solution is YES! OF COURSE!

Leaving that’s long and boring introduction I think that algorithms are not only a way to solve problems but a tool that allows us, not only geeks or nerds, to find other possible better solutions or to confirm that our one is the best one.
So, if you have a look at the icon, that is taken by the Princeton website, you should consider the opportunity to think a problem as something that has to be solved through organized iterations not only as an intuition.

#Java @nnotations

“Annotations, a form of metadata, provide data about a program that is not part of the program itself. Annotations have no direct effect on the operation of the code they annotate.

Java Tutorial – Oracle (Sun)

Definition:

public @interface <name>{

<type> <method_name>();

<type> <method_name>() default <value>;

}

  • @Retention annotation specifies how the marked annotation is stored:
    • RetentionPolicy.SOURCE – The marked annotation is retained only in the source level and is ignored by the compiler.
    • RetentionPolicy.CLASS – The marked annotation is retained by the compiler at compile time, but is ignored by the Java Virtual Machine (JVM).
    • RetentionPolicy.RUNTIME – The marked annotation is retained by the JVM so it can be used by the runtime environment.
  • @Target annotation marks another annotation to restrict what kind of Java elements the annotation can be applied to. A target annotation specifies one of the following element types as its value:
    • ElementType.ANNOTATION_TYPE can be applied to an annotation type.
    • ElementType.CONSTRUCTOR can be applied to a constructor.
    • ElementType.FIELD can be applied to a field or property.
    • ElementType.LOCAL_VARIABLE can be applied to a local variable.
    • ElementType.METHOD can be applied to a method-level annotation.
    • ElementType.PACKAGE can be applied to a package declaration.
    • ElementType.PARAMETER can be applied to the parameters of a method.
    • ElementType.TYPE can be applied to any element of a class.
  • @Inherited annotation indicates that the annotation type can be inherited from the super class. (This is not true by default.) When the user queries the annotation type and the class has no annotation for this type, the class’ superclass is queried for the annotation type. This annotation applies only to class declarations.

Read the rest of this entry

[TUTORIAL] Working in the background

In this tutorial we’ll talk some aspects that involves a mobile developer in many situations. In particular we’ll deepen concepts like threads (in particular AsyncTasks) and JSON parsing through Google GSON.

This slideshow requires JavaScript.

Before you start, take a look at:

Now you are ready to perform this simple steps:

  1. Take TWITTER_URL that you find in the project in AsyncTaskActivity
  2. Past it into JSONLint board and press Validate

In this way you’ll view if your JSON is valid and how it’s structured.

After that you need to create (there’s mine 😛 ) an android project in which you add into AndroidManifest.xml the internet permission and an Activity that’ll be your ListActivity implementation. It’s important to that because our application uses an Internet connection to contact Twitter servers. After that you need to prepare your xml layouts and resources: you’ll find them into res folder.

Now there is the core of your application that it’s related to code implementation and in particular to the AsyncTaskActivity and HTTPUtil that you can read in the attached project.

  • HTTPUtil: it’s a very simple utility class that performs a get request and returns the result as String
  • AsyncTaskActivity: it’s the ListActivity implementation that I have provided to allow you to download some tweets from Twitter and show them on screen

Into your ListActivity implementation to avoid to stop your main UI Thread we’ll implement the data fetching into a background Thread. That’s not a good practise but a must that grants to user a good experience and  to avoid “Your application has unexpectedly…. bla bla”. Hence, I have provide an implementation of AsyncTask that allows you to perform into the background the following operations:

  • contact Twitter servers
  • retrieve JSON response
  • parse response into a List of Tweets

In fact all these operations are performed into doInBackground(….) method. All those updates those involves UI, in our case list refresh, are done in the UI thread and for that are done in onPostExecute(…). Pay attention that if you perform these actions out of your main Thread you get a fatal error and your app crashes relentlessly. If you try this tutorial on your mobile phone or into emulator you’ll obtain the screens that you can see in the SlideShow.

The solution that I have provided is very simple and there are other mechanism that connected to data persistance grants to user a better UE (user-experience).

I hope that this tutorial will be very helpful,

Simone

Is android difficult or simply too wide?

I have heard that many new android developers are afraid by this platform because they consider it too difficult and for that they try to find many different reasons to prefer other alternatives. I think that these kind of suppositions are not completely true because in other platform you’ll not find better tools, api’s or whatever you want.

On one hand I think that android can be difficult because it’s full of functionalities and because it has some mechanisms (Intents and Receivers) those are not too easy but very powerful. On the other hand it’s not too easy to create standard apps because the pelvis of different kind of devices forces you to create different UIs and solutions.

At the same time this powerful platform and pretty way of think offers you many opportunities:

  • Good and very wide support in documentation, forums and blogs
    (StackOverFlow is a very nice place where you can find answers to your questions)
  • Deep control on device features (Sensors, Services,…)
  •  Narrow limits to your ideas (you can provide your own email app or implement social apps)
  • Possibility to check your UIs with many emulators and sizes
  • ….

After two year of developing, I have acquired a pretty good familiarity with this platform but I think that you can reach a good level in just few months. All that you have to do is a sort of self training with android sdk across examples and good tutorials that you can find on the web. If some years ago the documentation could be skinny, now it has become a fantastic encyclopedia where you can find optimal solutions to your problems.

I hope that many of the escaped developers will reconsider the opportunity to study in deep the new features offered by ICS and HoneyComb.

Not only another WordPress

In these days I’m populating this new home for me, my android apps, my knowledges and many of the things that are related to me.
As you can see in the section About me, I’m still a student but at the same time I’m an android and Java developer who is growing through the new technologies of the last years.
I have chosen WordPress to share with you a part of my life because I consider it a simply but very powerful way to mantain blogs and because I think that it’s well structured for web crawlers and Internet backbone.

In the next articles, I’ll present you some of my android apps that you can find on the android market and a part of my actual interests and works.

See you to next post,
Simone