Category Archives: Android

(English) Adding backendless sync to existing offline app with Firebase

Není k dispozici v češtině. For the sake of viewer convenience, the content is shown below in the alternative language. You may click the link to switch the active language.

My application Reader‘s Diary is on Google Play store for more than 4 years. It was my first more complex application when I started self-learning programming. And you can guess that from some still remaining fragments of horrible code:) I wrote application primarily for myself, I use it whenever I start or finish reading a book. However, during these years it found few hundred active users. As my coding and UI skills improved, so has app, and now it is quite different from it‘s first version. Some poor initial design choices are however still there.

Planning new version

I was quite happy with the previous version. It fulfilled all my needs. Not taking small fix into account, it was in store for 18 months. In the meantime, I got some requests from users. Some wanted to sync their books, some wanted to add book cover pages. Showing cover images was an easy thing. I already have a function to search books by ISBN code using Google Books service so I only needed to save image url from the search result. For sync, I decided to use Firebase.
Continue reading

(English) What is Application class good for?

Není k dispozici v češtině. For the sake of viewer convenience, the content is shown below in the alternative language. You may click the link to switch the active language.

The Application class is the base class of Android application. It is the first class that is initialized when the app is started. Therefore you can initialize here everything that needs to be ready when an activity or other application component is started.

When to override Application class?

Application class doesn’t have to be overridden all the time. I presume most of simple apps can use default Application class implementation without problems. Android documentation states that

There is normally no need to subclass Application. In most situations, static singletons can provide the same functionality in a more modular way. If your singleton needs a global context (for example to register broadcast receivers), include Context.getApplicationContext() as a Context argument when invoking your singleton’s getInstance() method.

Main reasons to override Application class are following:
• Getting access to the Application Context
• Global initialization
• Getting access to global methods and data
Continue reading