Java – Which class implements ContextWrapper’s method in Android?

Which class implements ContextWrapper’s method in Android?… here is a solution to the problem.

Which class implements ContextWrapper’s method in Android?

When developing Android applications, I like to look at the internal SDK implementation. This is a huge framework, and sometimes it helps a lot if you know how internal methods are implemented.

Now the last source code check I did really confused me. I looked at the Context class to read some implementation. Unfortunately, most of them are abstract, which is why Android invented ContextWrapper, a simple adapter pattern.

The problem is, I can’t find some methods that interest me. Let’s take getResources as an example. I have a ContextObject and call getResources on it. This Context is an instance of the activity (it does not implement getResources()).

The same is true for ContextThemeWrapper, which is the direct parent of an activity. ContextWrapper then calls getResources() on its Context member. But who is implementing it?

Edit: Add a snippet from ContextWrapper

public class ContextWrapper{
    Context mContext

public ContextWrapper(Context ctx){
        mContext = ctx

public Resourced getResources(){
        return mContext.getResources()

//... all other Methods are implementing the same AdapterPattern

So the question can also be “which context is passed to ContextWrapper, which is implementing the required method”


With helpful tips from nicholas.hausschild, I finally found it myself, just to run the debugger.

Unfortunately, this seems to be the only method, since it’s implemented in a class called ContextImpl, which is package-readable (although not documented). You must install the Eclipse source-code plugin (if you have downloaded the Android-SDK and linked it to eclipse, it may seem a bit problematic to install) to see the source code.

For anyone interested in these sources: clickme

Related Problems and Solutions