Android Get Application Context

When we are inside an Activity, and we need the application context we can use

 method. But what if we are not inside an Activity and we need the application context? Well, I will explain in this tutorial how you can get the context of the application outside an Activity.

You have to create a new class called “ApplicationContextProvider” which will provide the context wherever in the application. The code looks like this:

Now you have to declare this class in the AndroidManifest.xml in the application tag:

And that’s all. You can get now the application context wherever you need it by simply calling

NOTE: The Application Context can be used to load resources, send broadcast messages and do other system like stuff and NOT on instantiating Views !


Sponsored message:

Programming Tip : Worried about your incomplete/pending software project? Now you can remotely catch up with your pending/missing programming work by accessing your programming tools such as emulators/IDE`s on high performance citrix xendesktop from CloudDesktopOnline with cheapest xendesktop cost. Now you can add complete MS Office suite to the same xendesktop by visiting powered by Apps4Rent.

Set the application icon

To set the application icon in Android you have to open the project’s Manifest.xml file and add the following attribute to the application tag:

Before you do that make sure you add the icon image in one of your drawable directories.. If you called your icon: app_icon.png then the application tag should look like this:

I hope this helps someone 🙂

PS: pay attention to your resources names.. use “_” as separator instead of “-” or space, otherwise you will get errors in your project.

Android Number Series

Hi, today I want to present my new application Number Series.

Number Series is a logical game with numbers, just perfect for you if you like to challenge your brain.
You have to go through 10 levels with varying degree of difficulty and you have only 3 lives to complete the game. What do you have to do? It’s simple. In each level a sequence of numbers appears and you must figure out which is the number that follows.

When you lose a life a Show Explanation button will appear and if you click on it you can see the answer but you will lose one life. When you end the game or lose all your lives you can introduce your name and save the level you reached in the high score list.
Have fun while training your mind 🙂

Please feel free to install our new game and rate it on Google Play 🙂