Caching Bitmap bug at developer.android.com
<p>I was just reading tutorial of caching bitmaps from url at <a href="http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html" rel="nofollow">developer.android.com</a></p>

<p>refering to code</p>

<pre><code>    private LruCache&lt;String, Bitmap&gt; mMemoryCache;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        ...
        // Get memory class of this device, exceeding this amount will throw an
        // OutOfMemory exception.
        final int memClass = ((ActivityManager) context.getSystemService(
                Context.ACTIVITY_SERVICE)).getMemoryClass();

        // Use 1/8th of the available memory for this memory cache.
        final int cacheSize = 1024 * 1024 * memClass / 8;

        mMemoryCache = new LruCache&lt;String, Bitmap&gt;(cacheSize) {
            @Override
            protected int sizeOf(String key, Bitmap bitmap) {
                // The cache size will be measured in bytes rather than number of items.
                return bitmap.getByteCount();
            }
        };
        ...
    }

    public void addBitmapToMemoryCache(String key, Bitmap bitmap) {
        if (getBitmapFromMemCache(key) == null) {
            mMemoryCache.put(key, bitmap);
        }
    }

    public Bitmap getBitmapFromMemCache(String key) {
        return mMemoryCache.get(key);
    }

public void loadBitmap(int resId, ImageView imageView) {
    final String imageKey = String.valueOf(resId);

    final Bitmap bitmap = getBitmapFromMemCache(imageKey);
    if (bitmap != null) {
        mImageView.setImageBitmap(bitmap);
    } else {
        mImageView.setImageResource(R.drawable.image_placeholder);
        BitmapWorkerTask task = new BitmapWorkerTask(mImageView);
        task.execute(resId);
    }
}
</code></pre>

<p>in activity cache is beign initialize and there are two methods </p>

<ol>
<li><p><strong><code>addBitmapToMemoryCache(String key, Bitmap bitmap)</code></strong></p></li>
<li><p><strong><code>getBitmapFromMemCache(String key)</code></strong></p></li>
</ol>

<p>here is the BitmapWorkerTask class</p>

<pre><code>class BitmapWorkerTask extends AsyncTask&lt;Integer, Void, Bitmap&gt; {
    ...
    // Decode image in background.
    @Override
    protected Bitmap doInBackground(Integer... params) {
        final Bitmap bitmap = decodeSampledBitmapFromResource(
                getResources(), params[0], 100, 100));
        addBitmapToMemoryCache(String.valueOf(params[0]), bitmap);
        return bitmap;
    }
    ...
}
</code></pre>

<p>now my question is that in <strong>BitmapWorkerTask</strong> class how come method <strong>addBitmapToMemoryCache(String.valueOf(params[0]), bitmap);</strong> is called with having any reference to the methods that are defined in Activty or might be in some other Class</p>
