Today I want to talk about Context in Android. As you know, whether we’re attaching a view or get an asset, – almost always there is a reference to Context. From the documentation, Context is an interface to global information about an application environment. This is an abstract class whose implementation is provided by the Android system. It allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc.
On the one hand, we all know it and use it, on the other – we often use it in a wrong way or just don’t care enough whether garbage collector will clean it or will the context be hanging there somewhere or, even worse, cause a memory leakage. So, what are the ways of getting a context? A couple actually:
- this / getActivity()
Continue reading What is it about Context in Android?
It’s been a long time since I talked about my app’s release, but finally this day came! Today, I want to present you Look Counter – a simple app for counting how many times a day you have turned on and unlocked your phone (or tablet). It counts this in background and displays the latest numbers on the main view. You, as a user, can delete this data at any moment of time (Clear all Data option, with a quick Undo if you change your mind).
I’ve put an About view, if somebody is confused with the minimalist design and doesn’t follow what those numbers in circles mean, or maybe, wants to contact me right away, and say that counting doesn’t work for him at all! 😛
Anyway, the source code is on GitHub, so you can check what’s inside and grab tasty pieces, as well as point me at my mistakes 😉
Continue reading Look Counter app and more!
Today I will show you how to benefit from Handlers in Android 🙂
First of all, Handlers aren’t some new concept, they were there long ago. How long? Well, from API level 1. Still, I always felt Android developers don’t use them enough, me included.
When I’ve discover the brilliance of Handlers, I was surprised how handy they are and how easy is to use them.
So, what does a Handler do? A few things, really.
Continue reading Tutorial: How to use a Handler?
Today I want to present you a new JSON-parsing library – LoganSquare, written by BlueLine Labs. It is told to be the fasted available and quite easy to use, so I couldn’t miss it 😉 Below you will find an example Android project, which serializes and parses some objects.
Also, I have run Logan’s Benchmark project myself and indeed, the results are good. Not as good, as on their GitHub’s page, but still. Just to make everything clear, I have used Nexus 5 running Android 6.0.1 (ART).
As you can see, LoganSquare wins in every category. Lets check how we can use it in our project, shall we?
Continue reading Tutorial: Parse JSON with LoganSquare