What is it about Context in Android?

Hi,

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()
  • getContext()
  • getBaseContext()
  • getApplicationContext()

Continue reading What is it about Context in Android?

Like and share:

Tutorial: How to use a Handler?

Hello,

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?

Like and share: