title: Pass data from View class to Activity class in Android
body: <p>In my android application, I'm going to color a bird sketch. I need to color each part of the bird with various colors. I identify those parts with screen co-ordinates of this bitmap. Now what I need is, when user touch the area of a body part, then to open an another window which has color list. For that I need to pass data from my View class to new Activity class. How can I do that? Please give a help!     </p>
  
  <p><strong>My View Class</strong></p>
  
  <pre><code>class BirdColors extends View{
  
      private Paint paint;
      public Bitmap mBitmap,nBitmap;
      public Canvas canvas;
      private int x,y;
      private CreateColorList colorList;
      int val;
  
      public BirdColors(Context context) {
          super(context);
          // TODO Auto-generated constructor stub 
          paint=new Paint();
          paint.setAntiAlias(true);   
          paint.setStyle(Paint.Style.STROKE);
          paint.setStrokeJoin(Paint.Join.ROUND);
  
          mBitmap=BitmapFactory.decodeResource(getResources(), R.drawable.birdsketchfinal2).copy(Config.ARGB_8888, true);
  
  
          mBitmap= Bitmap.createScaledBitmap(mBitmap, 230, 230, true);
          //mBitmap=nBitmap;
      }
  
      @Override
      protected void onDraw(Canvas canvas) {
          // TODO Auto-generated method stub
          super.onDraw(canvas);
  
  
          this.canvas=canvas;
          canvas.drawBitmap(mBitmap,0,0, null);
          //canvas.drawText("Shashika", 10, 50, paint);
          canvas.drawText("Screen Cordinates" +x+"x"+y, 10, 220, paint);
  
  
      }
  
      @Override
      public boolean onTouchEvent(MotionEvent event) {
          // TODO Auto-generated method stub
           switch(event.getAction()){
  
          case MotionEvent.ACTION_DOWN:
  
              x=(int)event.getX();
              y=(int)event.getY();
  
              if((x&gt;5 &amp;&amp; x&lt;23)&amp;&amp;(y&gt;30 &amp;&amp; y&lt;47)){
  
                      val=1;
                      //colorList=new CreateColorList(val);
                      //In here I need to pass the val 
  
              }
              invalidate();
           }
          return true;
      }
  </code></pre>