The normal solution to this is to pass an instance of the context to the class as you create it, or after it is first created but before you need to use the context.
Another solution is to create an Application object with a static method to access the application context although that couples the Droid object fairly tightly into the code.
Edit, examples added
Either modify the Droid class to be something like this
public Droid(Context context,int x, int y) {
this.bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.birdpic);
this.x = x;
this.y = y;
}
Or create an Application something like this:
public class App extends android.app.Application
{
private static App mApp = null;
/* (non-Javadoc)
* @see android.app.Application#onCreate()
*/
@Override
public void onCreate()
{
super.onCreate();
mApp = this;
}
public static Context context()
{
return mApp.getApplicationContext();
}
}
And call App.context() wherever you need a context - note however that not all functions are available on an application context, some are only available on an activity context but it will certainly do with your need for getResources().
Please note that you'll need to add android:name to your application definition in your manifest, something like this:
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:name=".App" >