title: How to call getResources() from a class which has no context?
body: <p>In my application I have many classes and activities. Droid is a class which does not have context. Mygame is a class which extends SurfaceView and implements SurfaceHolder.Callback.
  I am creating an object of Droid in mygame class and setting the background image and position for it. The code I have written for this is given below.</p>
  
  <pre><code>block1 = new Droid(BitmapFactory.decodeResource(getResources(), R.drawable.birdpic), 100, 10);
  </code></pre>
  
  <p>The constructor of Droid class is given below.</p>
  
  <pre><code>public Droid(Bitmap bitmap, int x, int y) {
  
      this.bitmap = bitmap;
      this.x = x;
      this.y = y;
  }   
  </code></pre>
  
  <p>In a particular scenario i have to set the background image and position of the Droid object from the Droid class itself.Here i am facing the issue.Given below is the code snippet to do this.</p>
  
  <pre><code>if(checkflag)
  {
      myObj.centerblock=new Droid(BitmapFactory.decodeResource(getResources(), R.drawable.blast), myObj.xpos, myObj.ypos);
  }   
  </code></pre>
  
  <p>The problem is that the Droid class has no context. So I cannot use getResources() here. I have tried the code below but it crashes.</p>
  
  <pre><code>if(checkflag)
  {
      myObj.centerblock=new Droid(BitmapFactory.decodeResource(myObj.getResources(), R.drawable.blast), myObj.xpos, myObj.ypos);
  }
  </code></pre>
  
  <p>Can anybody help me. I just want to set the background image and position it for the Droid object from the Droid class itself.  </p>